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.

Author serhiy.storchaka
Recipients bjkeen, serhiy.storchaka, skrah
Date 2020-04-29.21:56:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1588197365.33.0.324301526414.issue40440@roundup.psfhosted.org>
In-reply-to
Content
array.array should copy the content, to be able to modify it. It implements both the storage for data and the view of that storage.

What you want is already implemented as the memoryview object.

>>> import array
>>> x = array.array('b', [1,2,3,4])
>>> x
array('b', [1, 2, 3, 4])
>>> z = memoryview(x).cast('h')
>>> z
<memory at 0x7f31e79d2c80>
>>> list(z)
[513, 1027]
>>> z[0] = 42
>>> x
array('b', [42, 0, 3, 4])
>>> x.append(4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
BufferError: cannot resize an array that is exporting buffers
History
Date User Action Args
2020-04-29 21:56:05serhiy.storchakasetrecipients: + serhiy.storchaka, skrah, bjkeen
2020-04-29 21:56:05serhiy.storchakasetmessageid: <1588197365.33.0.324301526414.issue40440@roundup.psfhosted.org>
2020-04-29 21:56:05serhiy.storchakalinkissue40440 messages
2020-04-29 21:56:05serhiy.storchakacreate