This discussion might be of interest (from python-3000.devel): Antoine Pitrou wrote:
Josiah Carlson <josiah.carlson <at> gmail.com> writes:
From what I understand of the memoryview when I tried to do the same thing a few months ago (use memoryview to replace buffer in asyncore/asynchat), memoryview is incomplete. It didn't support character buffer slicing (you know, the 'offset' and 'size' arguments that were in buffer), and at least a handful of other things (that I can't remember at the moment).
You should try again, memoryview now supports slicing (with the usual Python syntax, e.g. m[2:5]) as well as slice assignment (with the fairly sensible limitation that you can't resize the underlying buffer). There's no real doc for it, but you can look at test_memoryview.py in the Lib/test directory to have a fairly comprehensive list of the things currently supported.
I also support the addition of official functions or macros to access the underlying fields of the Py_buffer struct, rather than access them directly from 3rd party code. Someone please open an issue for that in the tracker.
The big, big limitation of memoryviews right now is that they only support one-dimensional byte buffers. The people interested in more complex arrangements (that is, Scipy/Numpy people) have been completely absent from the python-dev community for many months now, and I don't think anyone else cares enough to do the job instead of them.
Regards
Antoine.
On Tue, Nov 25, 2008 at 11:45 AM, Neal Becker <ndbecker2@gmail.com> wrote:
This discussion might be of interest (from python-3000.devel):
Antoine Pitrou wrote:
Josiah Carlson <josiah.carlson <at> gmail.com> writes:
From what I understand of the memoryview when I tried to do the same thing a few months ago (use memoryview to replace buffer in asyncore/asynchat), memoryview is incomplete. It didn't support character buffer slicing (you know, the 'offset' and 'size' arguments that were in buffer), and at least a handful of other things (that I can't remember at the moment).
You should try again, memoryview now supports slicing (with the usual Python syntax, e.g. m[2:5]) as well as slice assignment (with the fairly sensible limitation that you can't resize the underlying buffer). There's no real doc for it, but you can look at test_memoryview.py in the Lib/test directory to have a fairly comprehensive list of the things currently supported.
I also support the addition of official functions or macros to access the underlying fields of the Py_buffer struct, rather than access them directly from 3rd party code. Someone please open an issue for that in the tracker.
The big, big limitation of memoryviews right now is that they only support one-dimensional byte buffers. The people interested in more complex arrangements (that is, Scipy/Numpy people) have been completely absent from the python-dev community for many months now, and I don't think anyone else cares enough to do the job instead of them.
What is memoryview? Chuck
On Tue, Nov 25, 2008 at 6:19 PM, Charles R Harris <charlesr.harris@gmail.com> wrote:
What is memoryview?
Take a look at the new c-api calls in the buffer protocol PEP: http://www.python.org/dev/peps/pep-3118/#new-c-api-calls-are-proposed -- Jarrod Millman Computational Infrastructure for Research Labs 10 Giannini Hall, UC Berkeley phone: 510.643.4014 http://cirl.berkeley.edu/
participants (3)
-
Charles R Harris -
Jarrod Millman -
Neal Becker