Message260261
Just noticed when answering a question on StackOverflow (http://stackoverflow.com/q/35387843/918959) that on Python 3 iterating over a mmap object yields individual bytes as bytes objects, even though iterating over slices, indexing and so on gives ints
Example:
import mmap
with open('test.dat', 'rb') as f:
mm = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
for b in mm:
print(b)
# prints for example b'A' instead of 65
mm.close()
I believe this should be fixed for the sake of completeness - the documentation says that "Memory-mapped file objects behave like both bytearray and like file objects." - however the current behaviour is neither like a bytearray nor like a file object, and quite confusing.
Similarly the `in` operator seems to be broken; one could search for space using `32 in bytesobj`, which would work for slices but not for the whole mmap object. |
|
Date |
User |
Action |
Args |
2016-02-14 03:37:46 | ztane | set | recipients:
+ ztane |
2016-02-14 03:37:46 | ztane | set | messageid: <1455421066.19.0.307034706486.issue26358@psf.upfronthosting.co.za> |
2016-02-14 03:37:46 | ztane | link | issue26358 messages |
2016-02-14 03:37:44 | ztane | create | |
|