At the moment mostly a drop-in replacement for the bitstream library.
The bitstream library was too slow for the purposes I needed it for, this library has better performance. Specifically I wanted to scan along for a given sequence and then start decoding from there. bitstream isn't designed to seek along, constantly saving and restoring state.
- You want a nice interface for dealing with things at the bit level
- You need to seek along your data
- It needs to be relatively fast
from bitstream_python import BitStream
from numpy import *
stream = BitStream()
stream.write(True, bool)
stream.write(0xFF, uint8)
assert(stream.read(bool, 9) == [True] * 9)
stream.write([1,0,1,0], bool, 4)
stream.write([1,0,1,1], bool, 4)
stream.write(0xCD, uint8)
assert(stream.read(uint16) == 0xABCD)
Write one thing stream.write(value, type)
Read one thing stream.read(type)
Write many things stream.write([value, value, ...], type, length)
Read many things stream.read(type, length)
To run:
- numpy
To build/install:
- Cython
- numpy
To test:
- Cython
- numpy
- py.test
- hypothesis
- robber
- Install required dependencies
- Run
$ python setup.py install
- Install required dependencies
- Run
$ python setup.py install test
Licensed under the MIT License, refer to LICENSE.md for more information.