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