Antoine Pitrou wrote:
That doesn't work if e.g. you take a slice of a memoryview object, since the shape changes in the process. See http://bugs.python.org/issue4580
I haven't looked in detail at how memoryview is currently implemented, but it seems to me that the way it should work is that whenever you access a slice, it obtains a fresh Py_Buffer from the underlying object, and does the right thing based on the shape/strides from that together with the slice ranges. The only time it should need to allocate its own shape/strides is if you request a Py_Buffer from the memoryview itself, at which time it should obtain a Py_Buffer from the underlying object, update its own shape/strides and pass them to the caller. The underlying Py_Buffer lock should be held until the caller releases the memoryview's Py_Buffer, ensuring that its shape/strides remains valid for as long as they're needed. -- Greg _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com