[Python-Dev] PEP 3118: Extended buffer protocol (new version) (original) (raw)

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Apr 12 03:35:42 CEST 2007


From PEP 3118:

A memory-view object is an extended buffer object that should replace the buffer object in Python 3K.

typedef struct { PyObject_HEAD PyObject *base; struct bufferinfo view; int itemsize; int flags; } PyMemoryViewObject;

If the purpose is to provide Python-level access to an object via its buffer interface, then keeping a bufferinfo struct in it is the wrong implementation strategy, since it implies keeping the base object's memory locked as long as the view object exists.

That was the mistake made by the original buffer object, and the solution is not to hold onto the info returned by the base object's buffer interface, but to make a new buffer request for each Python-level access.

If that's not the purpose of this object, you need to explain what its purpose actually is.

Also some of what you say about this object is rather unclear, e.g. "It exports a view using the base object." I don't know what that is supposed to mean.

-- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | Carpe post meridiem! | Christchurch, New Zealand | (I'm not a morning person.) | greg.ewing at canterbury.ac.nz +--------------------------------------+



More information about the Python-Dev mailing list