On Jul 6, 2016 2:40 PM, "Michael Selik" <michael.selik@gmail.com> wrote:
>
> On Tue, Jun 7, 2016 at 4:30 PM Ethan Furman <ethan@stoneleaf.us> wrote:
>>
>> On 06/07/2016 12:57 PM, Nick Coghlan wrote:
>> > https://www.python.org/dev/peps/pep-0467/#addition-of-optimised-iterator-methods-that-produce-bytes-objects
>> >
>> > If someone wanted to take that PEP and drive it through to resolution,
>> > I'd be happy to hand it over (my recollection is that the sticking
>> > point in the previous discussion was the proposed constructor changes,
>> > so dropping those may make it easier to get the additional method
>> > accepted).
>>
>> Split new thread to resolve that PEP.
>
>
> What's the status of this PEP?
> Does anyone dislike the suggestion of adding an iterbytes method?
>
> I ran into this annoyance again yesterday. The natural way to ensure that all bytes in a bytes object are a particular value (in this case b'z') is:
>
>     all(byte == b'z' for byte in bytestring)
>
> It reads like natural language. Using ``ord`` would work in Python3, but then my code would not be Python2-compatible. And it'd uselessly repeat the call to ord a bunch of times.
>
>     all(byte == ord(b'z') for byte in bytestring)
>
> Instead it seems the best way given the current behavior is to write:
>
>     len(bytestring) == bytestring.count(b'z')
>
> While I wait for PEP 467, can anyone suggest a better way to write that?

How about
    set(bytestring) == set(b'z')