[Python-3000] Using memoryviews

Stefan Behnel stefan_ml at behnel.de
Thu Nov 27 11:03:26 CET 2008


M.-A. Lemburg wrote:
> I find the implementation of the buffer protocol way too complicated.
> One of the reasons why the buffer protocol in Python 2 never caught
> on was the fact that it was too complicated and the Python 3 is
> even worse in this respect.
> 
> In practice you do want to have the ability to hook directly into the
> data buffer of an object, but apart from some special needs that PIL
> and the numeric folks may have, most users will just want to work
> with a single contiguous chunk of memory and need a simple API to
> do this - pass in an object, get a void* back.

Cython makes it that easy to access a buffer (also in Python 2.3-2.5, BTW).
You only have to declare the type of a buffer variable.

http://wiki.cython.org/enhancements/buffer

According to what I hear, at least the NumPy developers make use of this
already. No idea how common it is in the PIL area, but it does work there, too.

Stefan



More information about the Python-3000 mailing list