New submission from Antoine Pitrou <pit...@free.fr>: 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') ---------- components: Interpreter Core messages: 81823 nosy: gregory.p.smith, ncoghlan, pitrou, teoliphant priority: normal severity: normal status: open title: Change format of a memoryview type: feature request versions: Python 3.1 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5231> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com