Message278497
Something else the PEP needs to be updated to cover is that in 3.5+ (and maybe even in 3.4 - I'm not sure when 'c' support landed in memoryview) you can write the following efficient bytes iterator:
def iterbytes(data):
return iter(memoryview(data).cast('c'))
And use it as so:
>>> data = b"123"
>>> for datum in iterbytes(data):
... print(datum)
...
b'1'
b'2'
b'3'
That will then work with any buffer exporter, not just bytes and bytearray, and since it's a function, you can easily make a similar function that's polymorphic on str -> str iterator and bytes-like -> bytes iterator. |
|
Date |
User |
Action |
Args |
2016-10-11 16:43:35 | ncoghlan | set | recipients:
+ ncoghlan, ned.deily, ethan.furman, elias, martin.panter, serhiy.storchaka, Rondom |
2016-10-11 16:43:35 | ncoghlan | set | messageid: <1476204215.02.0.256888048984.issue27923@psf.upfronthosting.co.za> |
2016-10-11 16:43:34 | ncoghlan | link | issue27923 messages |
2016-10-11 16:43:34 | ncoghlan | create | |
|