code: def packbools(bools, dtype='L'):
      
      r = NBITS[dtype]
      atoms = ATOMS[dtype]
  
      for chunk in zip_longest(*[iter(bools)] * r, fillvalue=False):
          yield sum(compress(atoms, chunk))
docs: Yield integers concatenating bools in chunks of dtype bit-length.
  
      >>> list(packbools([False, True, False, True, False, True], 'B'))
      [42]