Count the number of bits in a byte ``array``.

    It uses the Hamming weight popcount algorithm

def count_bytes(array):
    '''Count the number of bits in a byte ``array``.

    It uses the Hamming weight popcount algorithm
    '''
    # this algorithm can be rewritten as
    # for i in array:
    #     count += sum(b=='1' for b in bin(i)[2:])
    # but this version is almost 2 times faster
    count = 0
    for i in array:
        i = i - ((i >> 1) & 0x55555555)
        i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
        count += (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24
    return count