count number of set bits in a number python code example
Example: python count bits
counts = bytes(bin(x).count("1") for x in range(256)) # py2: use bytearray
counts = bytes(bin(x).count("1") for x in range(256)) # py2: use bytearray