An updated version of the bitmap library from https://github.com/wanji/bitmap
Project description
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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bitmap2-0.2.4.tar.gz
(8.4 kB
view details)
File details
Details for the file bitmap2-0.2.4.tar.gz.
File metadata
- Download URL: bitmap2-0.2.4.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
916d560002d1648f430fe80c417f97c71d0a950b16672e8b0e52bd5c1e5b8892
|
|
| MD5 |
b1822b25220e3b96e4fe4f44272a9860
|
|
| BLAKE2b-256 |
22c5a5cf5901ede31695a0ce0efad9978911c22367e39fbf21af19deb5bf9390
|