Message289570
Following example copies the entire buffer object while copying only smart part is needed:
m = memoryview(b'x'*10**6)
b'%.100b' % m
I don't know whether this is important use case that is worth an optimization. The workaround is using slicing rather than truncating in format:
b'%b' % m[:100]
Or in the case of general buffer object:
b'%b' % memoryview(m).cast('B')[:100]
But in that case it is not hard to add an explicit conversion to bytes.
b'%b' % bytes(memoryview(m).cast('B')[:100]) |
|
Date |
User |
Action |
Args |
2017-03-14 07:22:02 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, belopolsky, skrah, ethan.furman, xiang.zhang |
2017-03-14 07:22:02 | serhiy.storchaka | set | messageid: <1489476122.42.0.702433814121.issue28856@psf.upfronthosting.co.za> |
2017-03-14 07:22:02 | serhiy.storchaka | link | issue28856 messages |
2017-03-14 07:22:02 | serhiy.storchaka | create | |
|