Yield integers concatenating bools in chunks of dtype bit-length.

    >>> list(packbools([False, True, False, True, False, True], 'B'))
    [42]

def packbools(bools, dtype='L'):
    """Yield integers concatenating bools in chunks of dtype bit-length.

    >>> list(packbools([False, True, False, True, False, True], 'B'))
    [42]
    """
    r = NBITS[dtype]
    atoms = ATOMS[dtype]

    for chunk in zip_longest(*[iter(bools)] * r, fillvalue=False):
        yield sum(compress(atoms, chunk))