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

Mark Dickinson mdickinson at enthought.com
Mon Aug 22 08:35:56 EDT 2011


On Mon, Aug 22, 2011 at 1:30 PM, Stefan Krah <stefan-usenet at bytereef.org> wrote:
> Numpy arrays and memoryview currently have different representations
> for shape and strides if ndim = 0:
>
>>>> from numpy import *
>>>> x = array(9, int32)
>>>> x.ndim
> 0
>>>> x.shape
> ()
>>>> x.strides
> ()
>>>> m = memoryview(x)
>>>> m.ndim
> 0L
>>>> m.shape is None
> True
>>>> m.strides is None
> True
>
>
> I think the Numpy representation is nicer. Also, I think that memoryviews
> should attempt to mimic the underlying object as closely as possible.

Agreed on both points.  If there's no good reason for m.shape and
m.strides to be None, I think it should be changed.

Mark



More information about the NumPy-Discussion mailing list