Message284954
Isn't the proposed workaround also relying on CPython reference counting to immediately deallocate the sliced view? It fails if I keep a reference to the sliced view:
byteslike = bytearray(b'abc')
with memoryview(byteslike) as m1:
m2 = m1[1:]
bs = bytes(m2)
>>> byteslike += b'd'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
BufferError: Existing exports of data: object cannot be re-sized
It seems to me that it should be written as follows:
with memoryview(byteslike) as m1:
with m1[1:] as m2:
bs = bytes(m2)
>>> byteslike += b'd'
>>> byteslike
bytearray(b'abcd')
The memoryview constructor could take start, stop, and step keyword-only arguments to avoid having to immediately slice a new view. |
|
Date |
User |
Action |
Args |
2017-01-08 03:22:43 | eryksun | set | recipients:
+ eryksun, ncoghlan, belopolsky, vstinner, methane, Yury.Selivanov, serhiy.storchaka, yselivanov, xiang.zhang |
2017-01-08 03:22:43 | eryksun | set | messageid: <1483845763.9.0.721185667787.issue29178@psf.upfronthosting.co.za> |
2017-01-08 03:22:43 | eryksun | link | issue29178 messages |
2017-01-08 03:22:43 | eryksun | create | |
|