This package provides a BitMap class which is an array of bits stored in compact format.
bitmap can be installed from pip:
$ sudo pip install bitmapBitMap(maxnum): construct aBitMapobject withmaxnumbitsset(pos): set the bit at positionposto 1reset(pos): reset the bit at positionposto 0flip(pos): flip the bit at positionposcount(): return the number of 1ssize(): return the size of theBitMaptest(pos): check if bit at positionposhas been set to 1any(): check if any bit in theBitMaphas been set to 1none(): check if none of the bits in theBitMaphas been set to 1all(): check if all bits in theBitMaphas been set to 1nonzero(): return indexes of all non-zero bitstostring(): convert aBitMapobject to0and1stringfromstring(bitstring): create aBitMapobject from0and1string
from bitmap import BitMap
bm = BitMap(32)
print bm.tostring()
bm.set(1)
print bm.tostring()
bm = BitMap.fromstring("00011101")
print bm.tostring()
bm.flip(1)
print bm.tostring()