def list_to_bitfield(table):
  """Returns a bitfield array of each element that is bool(element) == True."""

  bitfield = [0x0] * (len(table) // 8 + (len(table) % 8 > 0))
  for i in range(len(table)):
    bitfield[i // 8] |= bool(table[i]) << (i % 8)
  return bitfield