[issue5231] Change format of a memoryview

Stefan Krah report at bugs.python.org
Tue Aug 23 15:10:41 CEST 2011


Stefan Krah <stefan-usenet at bytereef.org> added the comment:

I think this would be useful and I'll try it out in features/pep-3118#memoryview.

Syntax options that I'd prefer:

a = array.array('i', [1,2,3])
m = memoryview(a, 'B')


Or go all the way and make memoryview take any flag:

a = array.array('i', [1,2,3])
m = memoryview(a, getbuf=PyBUF_SIMPLE)


This is what I currently do in _testbuffer.c:


>>> from _testbuffer import *
>>> import array
>>> a = array.array('i', [1,2,3])
>>> nd = ndarray(a, getbuf=PyBUF_SIMPLE)
>>> nd.format
''
>>> nd.len
12
>>> nd.shape
()
>>> nd.strides
()
>>> nd.itemsize # XXX array_getbuf should set this to 1.
4



We would need to fix various getbuffer() methods to adhere to
strict rules that I've posed here:

http://mail.scipy.org/pipermail/numpy-discussion/2011-August/058189.html

----------
nosy: +skrah

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5231>
_______________________________________


More information about the Python-bugs-list mailing list