msg181541 - (view) |
Author: Demian Brecht (demian.brecht) *  |
Date: 2013-02-06 17:12 |
array.array doesn't implement the buffer interface in 2.7, so memoryviews cannot be applied to them. As memoryview has been backported to 2.7, array.array should be updated to support it. Either that, or the 2.7 documentation should be updated to reflect the lack of support for arrays in 2.7 (http://docs.python.org/2.7/c-api/buffer.html). python3 >>> memoryview(array('I', [1,2,3,4])) <memory at 0x109e46048> python >>> memoryview(array('I', [1,2,3,4])) Traceback (most recent call last): File "", line 1, in TypeError: cannot make memory view because object does not have the buffer interface |
|
|
msg181569 - (view) |
Author: Stefan Krah (skrah) *  |
Date: 2013-02-06 20:05 |
Changing array.array would be a new feature, so it cannot go into 2.7. The documentation could be improved, see also #14198. |
|
|
msg181624 - (view) |
Author: Demian Brecht (demian.brecht) *  |
Date: 2013-02-07 16:17 |
Here's a patch for the docs that adds a little clarity. |
|
|
msg181649 - (view) |
Author: Demian Brecht (demian.brecht) *  |
Date: 2013-02-07 23:02 |
Strike that patch, this needs a little more love than during-my-first-coffee-of-the-day work. I'll work on it more and submit a follow-up for review. |
|
|
msg182072 - (view) |
Author: Demian Brecht (demian.brecht) *  |
Date: 2013-02-14 03:50 |
I've given this some more thought and quite a bit more work and reorganization. I think this clarifies the usage of memoryviews and buffers as well as the C-level API for each. This is my first run at contributing a patch of any sort, so please let me know if there's anything further needed or any changes are required (or I'm just right out to lunch with this). |
|
|
msg182472 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2013-02-20 05:45 |
I am looking at this as a naive user, and can only assume that the claims are correct. +The new C-level buffer API has been backported to Python 2.6 and the +Python-level :class:`memoryview` object has been backported to Python 2.7. +To be clear, in Python 2.6 and 2.7, there are two C-level interfaces, both +exposed by the :ctype:`PyBufferProcs` interface: the new buffer API and the +old buffer API. The :class:`memoryview` object is the product of the new API +while :class:`buffer` is the product of the old API (the former of which is +only available in 2.7+). This part strikes me as a bit jumbled. Is it necessary to discuss 2.6 in 2.7 docs? the last parenthetical comment repeats what was said in an earlier sentence. Benjamin, I am adding you because you are listed as an author of the section being revised. |
|
|
msg182473 - (view) |
Author: Demian Brecht (demian.brecht) *  |
Date: 2013-02-20 06:21 |
Yes, I agree that passage is a little garbled. I've reworked that particular paragraph in the new patch. I had included a little information about 2.6 as it was in the revision prior to my patch (and there was also some historical context back to 1.6). I think that 2.6-specific information is irrelevant in this particular doc (after all, it's 2.7-specific and not a change log ;)) and therefore have removed it. |
|
|
msg194143 - (view) |
Author: Demian Brecht (demian.brecht) *  |
Date: 2013-08-02 00:32 |
Bump. If the patch (or request) is invalid, might be worthwhile closing this issue (although I still think it's valid ;)). |
|
|
msg196524 - (view) |
Author: Stefan Krah (skrah) *  |
Date: 2013-08-30 12:03 |
The request is certainly valid, but the patch is tricky to review. |
|
|
msg217214 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2014-04-26 20:51 |
New changeset 0a2ac61729d2 by Stefan Krah in branch '2.7': Issue #17145: Document array.array buffer interface limitations. http://hg.python.org/cpython/rev/0a2ac61729d2 |
|
|
msg217215 - (view) |
Author: Stefan Krah (skrah) *  |
Date: 2014-04-26 20:53 |
I pushed a minimal patch that focuses on the array.array issue. For broader changes, I suggest to use #14198 (though it is unlikely tha anyone will work on it). |
|
|