classification
Title: memoryview(array.array)
Type: enhancement Stage: patch review
Components: Documentation Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: benjamin.peterson, dbrecht, docs@python, mpb, pfalcon, skrah, terry.reedy
Priority: normal Keywords: patch

Created on 2013-02-06 17:12 by dbrecht, last changed 2014-04-08 13:15 by pfalcon.

Files
File name Uploaded Description Edit
buffer.patch dbrecht, 2013-02-07 16:17
buffer.patch dbrecht, 2013-02-14 03:50
buffer.1.patch dbrecht, 2013-02-20 06:21
Messages (9)
msg181541 - (view) Author: Demian Brecht (dbrecht) * 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 "<stdin>", line 1, in <module>
TypeError: cannot make memory view because object does not have the buffer interface
msg181569 - (view) Author: Stefan Krah (skrah) * (Python committer) 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 (dbrecht) * Date: 2013-02-07 16:17
Here's a patch for the docs that adds a little clarity.
msg181649 - (view) Author: Demian Brecht (dbrecht) * 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 (dbrecht) * 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) * (Python committer) 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 (dbrecht) * 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 (dbrecht) * 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) * (Python committer) Date: 2013-08-30 12:03
The request is certainly valid, but the patch is tricky to review.
History
Date User Action Args
2014-04-08 13:15:20pfalconsetnosy: + pfalcon
2013-11-21 08:12:31mpbsetnosy: + mpb
2013-08-30 12:03:09skrahsetmessages: + msg196524
2013-08-02 00:32:30dbrechtsetmessages: + msg194143
2013-02-20 06:21:24dbrechtsetfiles: + buffer.1.patch

messages: + msg182473
2013-02-20 05:45:42terry.reedysetnosy: + terry.reedy, benjamin.peterson

messages: + msg182472
stage: patch review
2013-02-14 03:50:15dbrechtsetfiles: + buffer.patch

messages: + msg182072
2013-02-07 23:02:47dbrechtsetmessages: + msg181649
2013-02-07 16:17:19dbrechtsetfiles: + buffer.patch
keywords: + patch
messages: + msg181624
2013-02-06 20:05:53skrahsetnosy: + docs@python, skrah
messages: + msg181569

assignee: docs@python
components: + Documentation, - None
2013-02-06 17:12:34dbrechtcreate