.
Project description
BitMap for python
This package provides a BitMap
class which is an array of bits stored in compact format.
Installation
bitmap
can be installed from pip
:
$ sudo pip install bitmap
Functions
BitMap(maxnum)
: construct aBitMap
object withmaxnum
bitsset(pos)
: set the bit at positionpos
to 1reset(pos)
: reset the bit at positionpos
to 0flip(pos)
: flip the bit at positionpos
count()
: return the number of 1ssize()
: return the size of theBitMap
test(pos)
: check if bit at positionpos
has been set to 1any()
: check if any bit in theBitMap
has been set to 1none()
: check if none of the bits in theBitMap
has been set to 1all()
: check if all bits in theBitMap
has been set to 1nonzero()
: return indexes of all non-zero bitstostring()
: convert aBitMap
object to0
and1
stringfromstring(bitstring)
: create aBitMap
object from0
and1
string
Examples
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()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bitmap-0.0.7.tar.gz
(3.4 kB
view hashes)
Built Distributions
bitmap-0.0.7-py3-none-any.whl
(3.9 kB
view hashes)
bitmap-0.0.7-py2-none-any.whl
(3.9 kB
view hashes)