[issue10181] Problems with Py_buffer management in memoryobject.c (and elsewhere?)

Stefan Krah report at bugs.python.org
Tue Jan 31 21:34:30 CET 2012

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

I've uploaded a new patch that should address the remaining issues:

   o In the documentation _testbuffer has been replaced by
     m.cast() + the now multi-dimensional m.tolist().

   o I restored the state of the limited API. If we want
     to include Py_buffer again, I think this should be done
     in a separate patch.

   o Flags of the memoryview object are private.

Additionally, because NumPy allows non-aligned array accesses,
I changed the packing functions to use memcpy for multi-byte types.

On x86/amd64 gcc is smart enough to produce almost exactly the same
asm output as before, with a slowdown of 0-1%, depending on the

On other platforms the situation might be worse, but I don't have
access to real hardware where alignment actually matters.


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list