[Python-Dev] Allocation of shape and strides fields in Py_buffer
Greg Ewing
greg.ewing at canterbury.ac.nz
Thu Dec 11 01:21:48 CET 2008
Nick Coghlan wrote:
> The multi-dimensional cases get pretty tricky though, since they will
> almost always end up dealing with non-contiguous data. The PEP 3118
> protocol is up to handling the task, but the implementation of the index
> mapping to handle these multi-dimensional cases is highly non-trivial,
> and probably best left to third party libraries like numpy.
I'm wondering whether there should be some kind of utility
function provided with the buffer API for doing this. It
would take the shape/strides info from a Py_buffer together
with a set of slicing parameters, and create you another
set of shape/strides info describing the slice.
It seems sensible to put the effort into doing this
correctly once, rather than leave everyone implementing
a memoryview-like object to come up with their own
half-working and/or broken implementation.
--
Greg
More information about the Python-Dev
mailing list