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

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Dec 9 23:54:08 CET 2008


Nick Coghlan wrote:

[from the PEP] "If the exporter wants to be able to change an object's shape, strides, and/or suboffsets before releasebuffer is called then it should allocate those arrays when getbuffer is called (pointing to them in the buffer-info structure provided) and free them when releasebuffer is called."

Even allowing this seems rather dubious to me. I suppose there's no serious danger as long as the block of memory ultimately holding the data doesn't move or change size, but changing the shape could confuse a buffer user that's iterating over the data.

-- Greg



More information about the Python-Dev mailing list