Message77533
The reason memoryview's current len() implementation is wrong is because
its indexing is per element in the original object, not per byte:
>>> a = array('i', range(10))
>>> m = memoryview(a)
>>> for i in range(len(m)):
... print(m[i])
...
b'\x00\x00\x00\x00'
b'\x01\x00\x00\x00'
b'\x02\x00\x00\x00'
b'\x03\x00\x00\x00'
b'\x04\x00\x00\x00'
b'\x05\x00\x00\x00'
b'\x06\x00\x00\x00'
b'\x07\x00\x00\x00'
b'\x08\x00\x00\x00'
b'\t\x00\x00\x00'
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
IndexError: index out of bounds
Oops. |
|
Date |
User |
Action |
Args |
2008-12-10 11:07:38 | ncoghlan | set | recipients:
+ ncoghlan, teoliphant, amaury.forgeotdarc, pitrou |
2008-12-10 11:07:38 | ncoghlan | set | messageid: <1228907258.56.0.867966783989.issue4580@psf.upfronthosting.co.za> |
2008-12-10 11:07:37 | ncoghlan | link | issue4580 messages |
2008-12-10 11:07:37 | ncoghlan | create | |
|