Revisiting memoryview.size: I foresee problems for NumPy users, since array.size
has a different meaning there:
>>> x = array([[1,2,3], [4,5,6]], dtype='q')
>>> x.shape
(2, 3)
>>> x.itemsize
8
>>> len(x)
2
>>> x.size
6
>>> x.nbytes
48
So here we have:
x.nbytes == product(shape) * itemsize == Py_buffer.len == (virtual!) byte length
x.size == product(shape) == number of elements
My suggestion is to use memoryview.nbytes as well. memoryview.size would have
the additional problem that Py_buffer.len is always the byte size of the logical
structure (e.g. after slicing) and not necessarily the byte size of the physical
memory area.