[issue9757] Add context manager protocol to memoryviews

2010-09-09 Thread Antoine Pitrou
Antoine Pitrou added the comment: Committed in r84649. Thanks for the comments! -- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed ___ Python tracker _

[issue9757] Add context manager protocol to memoryviews

2010-09-09 Thread Nick Coghlan
Nick Coghlan added the comment: Sounds good - I'd say just commit whenever you're happy with it then. -- ___ Python tracker ___ ___ Py

[issue9757] Add context manager protocol to memoryviews

2010-09-08 Thread Antoine Pitrou
Antoine Pitrou 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 that, since

[issue9757] Add context manager protocol to memoryviews

2010-09-08 Thread Nick Coghlan
Nick Coghlan 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? -- ___ Python

[issue9757] Add context manager protocol to memoryviews

2010-09-08 Thread Nick Coghlan
Nick Coghlan 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 buffer release pro

[issue9757] Add context manager protocol to memoryviews

2010-09-08 Thread Antoine Pitrou
Antoine Pitrou 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 __

[issue9757] Add context manager protocol to memoryviews

2010-09-07 Thread Nick Coghlan
Nick Coghlan 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 weren't > raised

[issue9757] Add context manager protocol to memoryviews

2010-09-07 Thread Antoine Pitrou
Antoine Pitrou 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 called all acc

[issue9757] Add context manager protocol to memoryviews

2010-09-07 Thread Guido van Rossum
Guido van Rossum 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 memoryview object sh

[issue9757] Add context manager protocol to memoryviews

2010-09-07 Thread Nick Coghlan
Nick Coghlan 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 mutable objects that ar

[issue9757] Add context manager protocol to memoryviews

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

[issue9757] Add context manager protocol to memoryviews

2010-09-03 Thread Antoine Pitrou
New submission from Antoine Pitrou : 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: Interpreter Core f