check if bytes is all nulls

Kirill Balunov kirillbalunov at gmail.com
Sun Apr 1 15:15:15 EDT 2018


2018-04-01 22:03 GMT+03:00 Kirill Balunov <kirillbalunov at gmail.com>:

>
>
> 2018-04-01 20:55 GMT+03:00 Arkadiusz Bulski <arek.bulski at gmail.com>:
>
>> What would be the most performance efficient way of checking if a bytes is
>> all zeros?
>
>
> Try `not any(key)` ;)
>
>
Sorry, I don't timed it before I posted. In reality, it is far from the
fastest, it is 10 times slower than `==`, but I like it:)

With kind regards,
-gdg


More information about the Python-list mailing list