This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients Rondom, elias, ethan.furman, martin.panter, ncoghlan, ned.deily, serhiy.storchaka
Date 2016-10-11.16:43:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1476204215.02.0.256888048984.issue27923@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-10-11 16:43:35ncoghlansetrecipients: + ncoghlan, ned.deily, ethan.furman, elias, martin.panter, serhiy.storchaka, Rondom
2016-10-11 16:43:35ncoghlansetmessageid: <1476204215.02.0.256888048984.issue27923@psf.upfronthosting.co.za>
2016-10-11 16:43:34ncoghlanlinkissue27923 messages
2016-10-11 16:43:34ncoghlancreate