Nick Coghlan <ncogh...@gmail.com> added the comment:

PEP 3118 makes it clear that the underlying object should see *two* pairs of 
calls to the buffer methods:
http://www.python.org/dev/peps/pep-3118/#the-py-buffer-struct

Even if we ignore the undocumented "obj" field, the target object needs to 
ensure the exported buffer remains valid as long as any memory views are 
referencing it. The only way to do that is to treat GetBuffer/ReleaseBuffer as 
the moral equivalent of INCREF/DECREF.

However, I believe the current memoryview implementation does the wrong thing 
and only calls them once, and then duplicates the Py_buffer structures without 
ever going back to the original objects (that opinion was based on a quick scan 
of the code a while back, but it would fit with the uncomplimentary sentiments 
Antoine has expressed in trying to get all this to exhibit some kind of 
consistency)

For point 2, it must be the same pointer. When the PEP says "the same", I agree 
it could be taken as ambiguous, but the later reference to the exporter 
managing a linked-list of exported views makes it clear that identity is what 
matters.

As far as I can see, some of things in the PEP were found to be a PITA in 
practice (such as every consumer of the API having to implement the equivalent 
of the "base" attribute in the original memoryview design), so Travis changed 
them. Unfortunately, those changes never made it back into the protocol 
documentation, leading to the current confusion.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue10181>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to