I'd like to use a compact & fast large bitfield in Python, ideally with no or few dependencies other than numpy
. The operations I'd like would be roughly equivalent to:
bits = new_bitfield(3000000) # 3 million bits
bits.set_bit(n, 1)
bits.set_bit(n, 0)
bits.get_bit(n)
I'd like the underlying storage for bits to be very condensed/low-overhead. (Ideally, that bits
object will only take a hairs'-breadth over 366.21 Kibibytes.)
I'd like the gets and sets to be very fast, with a minimum of type-checking/type-coercing overhead - perhaps even especially fast when using Cython- or Numba- specific code (or their respective inlining options).
What's the best way to approach C speed/compactness, while retaining as Pythonic of an outward appearance as is possible?