I don't have much to add to Nick's reply other than to point you to numpy, <http://projects.scipy.org/scipy/numpy>, as a reference implementation. You may also get better responses on the numpy list, < numpy-discussion at scipy.org>. On Mon, Dec 8, 2008 at 3:46 PM, Nick Coghlan <ncoghlan at gmail.com> wrote: > Antoine Pitrou wrote: >> For the one-dimensional case, I had in mind a simple scheme where the Py_buffer >> struct has an additional two-member Py_ssize_t array. Then `shape` and `strides` >> can point to the first and second member of this array, respectively. This >> wouldn't solve the multi-dimensional case, however. >> >> Thanks for any ideas on how to solve this. > > Actually, I think your suggested scheme for the one-dimensional case > shows the way forward: ownership of the shape and strides memory belongs > to the object issuing the Py_buffer struct, and that object needs to > deal with it when the buffer is released. Defining a larger memory chunk > with the Py_buffer as the first item and the shape and stride info > tacked onto the end and returning that from PyObject_GetBuffer() means > that the shape/stride info will be released automatically when the view > is released via PyBuffer_Release(). > > For more complicated cases, the object providing the views may need to > do some internally bookkeeping to map from Py_buffer pointers to > separately allocated shape/stride information and release those when the > views are released. > > Cheers, > Nick. > > -- > Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia > --------------------------------------------------------------- > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/alexander.belopolsky%40gmail.com >
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4