[issue9757] Add context manager protocol to memoryviews

2010-09-09 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: Sounds good - I'd say just commit whenever you're happy with it then. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9757 ___

[issue9757] Add context manager protocol to memoryviews

2010-09-09 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Committed in r84649. Thanks for the comments! -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org

[issue9757] Add context manager protocol to memoryviews

2010-09-08 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Here is a new patch adding the release() method as well. -- Added file: http://bugs.python.org/file18801/memcontext2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9757

[issue9757] Add context manager protocol to memoryviews

2010-09-08 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: On an eyeball review, the structure of do_release seems a little questionable to me. I'd be happier if view.obj and view.buf were copied to C locals and then set to NULL at the start of the function before any real work is done. I believe the

[issue9757] Add context manager protocol to memoryviews

2010-09-08 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: One other question: should IS_RELEASED use || rather than ? Is there any case where either of those pointers can be NULL and we still want to continue on rather than bailing out with a ValueError? --

[issue9757] Add context manager protocol to memoryviews

2010-09-08 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: On an eyeball review, the structure of do_release seems a little questionable to me. I'd be happier if view.obj and view.buf were copied to C locals and then set to NULL at the start of the function before any real work is done. You can't do

[issue9757] Add context manager protocol to memoryviews

2010-09-07 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: I closed 9789 as a duplicate of this. Bringing the details from that issue over here: memoryview objects currently offer no way to explicitly release the underlying buffer. This may cause problems for

[issue9757] Add context manager protocol to memoryviews

2010-09-07 Thread Guido van Rossum
Guido van Rossum gu...@python.org added the comment: Given this explanation, of course I am +1 on an explicit release() method. But I'm still skeptical that a context manager adds much (not sure if that counts as -0 or +0 :-). I suppose after release() is called all accesses through the

[issue9757] Add context manager protocol to memoryviews

2010-09-07 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Given this explanation, of course I am +1 on an explicit release() method. But I'm still skeptical that a context manager adds much (not sure if that counts as -0 or +0 :-). Ok, release() is probably enough. I suppose after release() is

[issue9757] Add context manager protocol to memoryviews

2010-09-07 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: Is this not covered by PEP 3118 at all? The PEP says “this memory view object holds on to the memory of base [i.e. the object the buffer was acquired from] until it is deleted”. Apparently issues pertaining to delayed garbage collection

[issue9757] Add context manager protocol to memoryviews

2010-09-03 Thread Antoine Pitrou
New submission from Antoine Pitrou pit...@free.fr: This adds the context manager protocol to memoryview objects, as proposed on python-dev. Once the `with` block has finished, the underlying buffer is released and any operation on the memoryview raises a ValueError. -- components:

[issue9757] Add context manager protocol to memoryviews

2010-09-03 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Guido expressed skepticism at the idea: http://mail.python.org/pipermail/python-dev/2010-September/103442.html -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9757