[issue10181] Problems with Py_buffer management in memoryobject.c (and elsewhere?)

Nick Coghlan report at bugs.python.org
Sun Feb 13 23:12:45 CET 2011


Nick Coghlan <ncoghlan at gmail.com> added the comment:

As far as the question of re-exporting the underlying view or not goes, I agree having "memoryview(a)" potentially refer to different underlying memory from "a" itself (because the source object has changed since the first view was exported) is a recipe for confusion. It is also important for ensuring memoryview slicing works correctly.

>From a didactic point of view, this would also have the benefit of providing a canonical example of managing exported Py_buffer structs in the CPython source code.

The "repeated slicing" issue is definitely a concern, though. If we declare memoryview objects officially immutable, then we can avoid that by shortcutting the chaining with a typecheck on the referenced object (i.e. call GetBuffer on the source object directly if it is a memoryview, but on the memoryview we're copying otherwise)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10181>
_______________________________________


More information about the Python-bugs-list mailing list