PyBitSet is a very simple Python library to create and manage bitsets.
$ git clone https://github.com/essessv/PyBitSet.git
$ cd PyBitSet
$ python setup.py install
The unit tests can be run using nosetests. There is a requirements.txt file included. To install the dependencies, run
$ pip install -r requirements.txt
to install nose in either a virtualenv or system as required.
To run the unit tests,
$ cd PyBitSet
$ nosetests -v
Once installed,
Python 2.7.5 (default, Sep 12 2013, 21:33:34)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pybitset.pybitset import BitSet
>>> b = BitSet(65535)
>>> b.size()
65535
>>> b.bitset_set(1000)
>>> b.bitset_is_set(999)
False
>>> b.bitset_is_set(1000)
True
>>> b.bitset_is_set(1001)
False
>>> b.bitset_set_range(start=65000, end=65100)
>>> b.bitset_count_set_bits()
102
>>> b.bitset_count_unset_bits()
65433
MIT
Free Software, Hell Yeah!