[Python-Dev] Allocation of shape and strides fields in Py_buffer

Antoine Pitrou solipsis at pitrou.net
Thu Dec 11 01:35:05 CET 2008

Greg Ewing <greg.ewing <at> canterbury.ac.nz> writes:
> This was a deliberate decision -- in fact I argued for it myself.
> The buffer interface is meant to be a minimal-overhead way for
> C code to get at the underlying data. Requiring allocation of
> a PyObject would be too expensive.

Tuples are used everywhere throughout the interpreter and yet they are proper
PyObjects. Even simple integers are often wrapped into PyLong objects (see the
getitem/setitem protocol in Py3k). I doubt Py_buffers are more critical for
performance than tuples and integers are.

More information about the Python-Dev mailing list