2 ms·
There are at least two silly things in this code, One is the hex conversion. Compare: >>> bin(int(binascii.hexlify(b"\x05"), 16))[2:] '101' versus just:
by kazinator 7y ago
There are at least two silly things in this code,
One is the hex conversion. Compare:
>>> bin(int(binascii.hexlify(b"\x05"), 16))[2:]
'101'
versus just:
>>> bin(b"\x05"[0])[2:]
'101'
Secondly, the code should just count the 1 bits; there is no need for a count of zeros.