Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:
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 ---------- nosy: +serhiy.storchaka, skrah _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40440> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com