[Numpy-discussion] memoryview shape/strides representation for ndim = 0

Stefan Krah stefan-usenet@bytereef....
Mon Aug 22 07:30:34 CDT 2011


Numpy arrays and memoryview currently have different representations
for shape and strides if ndim = 0:

>>> from numpy import *
>>> x = array(9, int32)
>>> x.ndim
>>> x.shape
>>> x.strides
>>> m = memoryview(x)
>>> m.ndim
>>> m.shape is None
>>> m.strides is None

I think the Numpy representation is nicer. Also, I think that memoryviews
should attempt to mimic the underlying object as closely as possible.

Since the ndim = 0 case probably only occurs in Numpy, it might be possible
to change the representation in memoryview.

Travis, was the "shape is None" representation used for compatibility with 
ctypes? Would it be possible or advisable to use the Numpy representation?

Stefan Krah

More information about the NumPy-Discussion mailing list