Faster C implementation of bitstruct
Maintained. Last release 3 weeks ago, commits in 2 of the last 26 weeks. Weaker on commit activity and contributor spread.
pip install cbitstructAbout
cbitstruct is a C implementation of the bitstruct library. Credits to Erik Moqvist for the original bitstruct library available on Github and pip.
The goal is to provide the same API an idealy to be able to interchange import bitstruct and import cbitstruct as bitstruct.
Obvious increased performance comes with limitations described below.
Installation
pip3 install cbitstruct
Documentation
Please refer to the bitstruct documentation as the aim of this library is to provide the same API with increased performance.
If you are not used to bitstruct, you should seriously consider using it first, before migrating to this library if you require higher performance.
Limitations
| Limitation | Will it be lifted ? |
|---|---|
| All types except padding are limited to 64 bits | Maybe for 'raw' and 'text' types |
| May not work on big-endian architectures | Maybe |
Exceptions differ from bitstruct | Probably not |
| CPython only | Probably not |
| Error messages are unclear | Will never be as clear as bitstruct |
| Python >= 3.5 | No |
Some limitations are there because I did not get the time or motivation to lift them up. Some other are deeply rooted into this library and may never be lifted.
Performance
Comparing to bitstruct
The script available in tests/test_perf.py measures performance comparing to the bitstruct library.
Here are the result "on my machine" (Ubuntu in Virtualbox on a laptop):