[Python-Dev] Allocation of shape and strides fields in Py_buffer (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Tue Dec 9 10:07:53 CET 2008


Antoine Pitrou wrote:

Nick Coghlan <ncoghlan gmail.com> writes:

No, you misunderstand what I meant. Pybuffer doesn't need to be changed at all. The issuing type would define a new structure with the additional fields, such as: With to the current buffer API, this is not possible. It's the caller who allocates the Pybuffer struct (usually on the stack), not the callee. Therefore the callee (e.g. the getbufferproc of the issuing type) cannot choose to allocate a different structure. (of course complex schemes can be devised where the callee maintains its own separate storage for shape and strides, but I don't think we want to go there)

In that case, as Greg noted, this is exactly what the callee should be doing. Maintaining a PyDict instance to map from view pointers to shapes and strides info doesn't strike me as a "complex scheme" though.

Cheers, Nick.

-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia



More information about the Python-Dev mailing list