Nick Coghlan added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27923>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com