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 pitrou
Recipients gregory.p.smith, ncoghlan, pitrou, teoliphant
Date 2009-02-12.21:39:01
SpamBayes Score 0.00020480814
Marked as misclassified No
Message-id <1234474743.76.0.794318305676.issue5231@psf.upfronthosting.co.za>
In-reply-to
Content
Memoryview objects provide a structured view over a memory area, meaning
the length, indexing and slicing operations respect the itemsize:

>>> import array
>>> a = array.array('i', [1,2,3])
>>> m = memoryview(a)
>>> len(a)
3
>>> m.itemsize
4
>>> m.format
'i'

However, in some cases, you want the memoryview to behave as a chunk of
pure bytes regardless of the original object *and without making a
copy*. Therefore, it would be handy to be able to change the format of
the memoryview, or ask for a new memoryview with another format.

An example of use could be:
>>> a = array.array('i', [1,2,3])
>>> m = memoryview(a).with_format('B')
>>> len(a), m.itemsize, m.format
(12, 1, 'B')
History
Date User Action Args
2009-02-12 21:39:03pitrousetrecipients: + pitrou, gregory.p.smith, teoliphant, ncoghlan
2009-02-12 21:39:03pitrousetmessageid: <1234474743.76.0.794318305676.issue5231@psf.upfronthosting.co.za>
2009-02-12 21:39:02pitroulinkissue5231 messages
2009-02-12 21:39:01pitroucreate