Python Count Bits

counts = bytes(bin(x).count("1") for x in range(256))  # py2: use bytearray
wolf-like_hunter