This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: memoryview(array.array)
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: benjamin.peterson, demian.brecht, docs@python, mpb, pfalcon, python-dev, skrah, terry.reedy
Priority: normal Keywords: patch

Created on 2013-02-06 17:12 by demian.brecht, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
buffer.patch demian.brecht, 2013-02-07 16:17
buffer.patch demian.brecht, 2013-02-14 03:50
buffer.1.patch demian.brecht, 2013-02-20 06:21
Messages (11)
msg181541 - (view) Author: Demian Brecht (demian.brecht) * (Python triager) 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 (

>>> memoryview(array('I', [1,2,3,4]))
<memory at 0x109e46048>

>>> 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 (demian.brecht) * (Python triager) 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) * (Python triager) 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) * (Python triager) 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 (demian.brecht) * (Python triager) 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) * (Python triager) 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.
msg217214 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-04-26 20:51
New changeset 0a2ac61729d2 by Stefan Krah in branch '2.7':
Issue #17145:  Document array.array buffer interface limitations.
msg217215 - (view) Author: Stefan Krah (skrah) * (Python committer) 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).
Date User Action Args
2022-04-11 14:57:41adminsetgithub: 61347
2014-04-26 20:53:53skrahsetstatus: open -> closed
resolution: fixed
messages: + msg217215

stage: patch review -> resolved
2014-04-26 20:51:08python-devsetnosy: + python-dev
messages: + msg217214
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:30demian.brechtsetmessages: + msg194143
2013-02-20 06:21:24demian.brechtsetfiles: + 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:15demian.brechtsetfiles: + buffer.patch

messages: + msg182072
2013-02-07 23:02:47demian.brechtsetmessages: + msg181649
2013-02-07 16:17:19demian.brechtsetfiles: + 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:34demian.brechtcreate