BitMap for python
An updated version of the bitmap library from https://github.com/wanji/bitmap since the original project is no longer maintained.
This package provides a BitMap class which is an array of bits stored in compact format.
Installation
bitmap can be installed from pip:
pip3 install bitmap2
Functions
BitMap(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 list of indexes of all non-zero bitsnonzeros(): return generator of indexes of all non-zero bitszero(): return list of indexes of all zero bitszeros(): return generator of indexes of all zero bitstostring(): convert aBitMapobject to0and1stringtofile(path): save aBitMapobject to a file onpathfromstring(bitstring): create aBitMapobject from0and1stringfromhexstring(hexstring): construct aBitMapobject from hex stringfromfile(path, maxnum): construct aBitmapobject from a file atpathof sizemaxnumbits
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()
Metadata
Release files for bitmap2 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bitmap2-0.2.5.tar.gz | 8.6 kB | Details |
Release files / bitmap2-0.2.5.tar.gz
| Download URL | bitmap2-0.2.5.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58c123b1ecf9fe646649986689b2b6e1a5f1ef109b6a185ed066e40be363ea3e
|
|
BLAKE2b-256 checksum How to use checksums |
6f861d7ce22e9a55916b218d65dc2619a6f7ca53599302a05caccc99c9348669
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|