A pure-Python memory-efficient packed representation for bit arrays
This class presents a pure-Python memory efficient packed representation for bit arrays.
Version 2.0.1 removes many typos and other errors in the documentation page. The implementation code remains the same as in Version 2.0
Version 2.0 provides much additional functionality that was requested by folks in the data mining community. The class now includes faster methods for counting bits, for finding the position of the next set bit, for calculating the rank of a bit, for determining the Jaccard and Hamming distances, etc. Also included in the new version are methods that should prove useful to folks who play with cryptography algorithms. There is now a method that calculates the greatest common divisor of two bit vectors and a method that finds the multiplicative inverse of a bit vector vis-a-vis a given modulus.
The class supports the following operators/methods:
__eq__, __ne__, __lt__, __le__, __gt__, __ge__
‘|’ for bitwise or
‘&’ for bitwise and
‘^’ for bitwise xor
‘~’ for bitwise inversion
‘<<’ for circular shift to the left
‘>>’ for circular shift to the right
‘+’ for concatenation
intValue(), __int__ for returning the integer value