Packing and unpacking bitvectors

Victor S. Miller victor at algebraic.org
Thu Oct 9 12:19:22 EDT 2003


I'm sure that this has been asked and answered before, but about 1/2
hour of searching hasn't turned up anything.

I have external data that requires the packing and unpacking of
long vectors of bits.  It's not hard to do this "by hand" in Python,
but surely there must be some more efficient package that does this.
The package struct doesn't seem to be applicable, since the shortest
unit that it deals with is a byte.  Given that various odd-sized
bitfields (as well as just straight bitvectors) are common enough, I
was surprised not find anything.

Can anyone help?

Victor




More information about the Python-list mailing list