Skip to main content

Faster C implementation of bitstruct

Project description

License Build Status Coverage Status

About

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):

byteswap list of int      | x  8.204 (   9.208us ->   1.122us)
byteswap str              | x  6.433 (   9.689us ->   1.506us)
calcsize                  | x149.423 (  61.967us ->   0.415us)
compiled pack             | x 43.227 (  34.758us ->   0.804us)
compiled pack_dict        | x 26.490 (  34.951us ->   1.319us)
compiled pack_into        | x 32.017 (  39.522us ->   1.234us)
compiled pack_into_dict   | x 26.817 (  38.984us ->   1.454us)
compiled unpack           | x 34.454 (  31.814us ->   0.923us)
compiled unpack_dict      | x 23.534 (  34.071us ->   1.448us)
compiled unpack_from      | x 27.170 (  31.884us ->   1.174us)
compiled unpack_from_dict | x 22.600 (  33.927us ->   1.501us)
pack                      | x 78.314 ( 105.593us ->   1.348us)
pack_dict                 | x 52.916 ( 106.748us ->   2.017us)
pack_into                 | x 82.233 ( 119.950us ->   1.459us)
pack_into_dict            | x 45.214 ( 111.338us ->   2.462us)
unpack                    | x 82.712 (  93.686us ->   1.133us)
unpack_dict               | x 41.064 (  91.473us ->   2.228us)
unpack_from               | x 81.678 (  95.729us ->   1.172us)
unpack_from_dict          | x 40.379 (  90.430us ->   2.240us)

Disclaimer: these results may and will vary largely depending on the number of elements and types you pack/unpack. This script is provided as-is, and I will gladly accept an improved script providing more reliable results.

The dict API

The dict API is marginally slower than the traditional one. As the packing/unpacking performance is quite high, the overhead of performing dictionary lookups and hashing significantly increas pack and unpacking duration.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cbitstruct-1.0.0.tar.gz (23.1 kB view details)

Uploaded Source

Built Distributions

cbitstruct-1.0.0-cp37-cp37m-win_amd64.whl (39.6 kB view details)

Uploaded CPython 3.7m Windows x86-64

cbitstruct-1.0.0-cp37-cp37m-manylinux1_x86_64.whl (59.4 kB view details)

Uploaded CPython 3.7m

cbitstruct-1.0.0-cp37-cp37m-manylinux1_i686.whl (56.4 kB view details)

Uploaded CPython 3.7m

cbitstruct-1.0.0-cp37-cp37m-macosx_10_12_x86_64.whl (35.7 kB view details)

Uploaded CPython 3.7m macOS 10.12+ x86-64

cbitstruct-1.0.0-cp36-cp36m-win_amd64.whl (39.6 kB view details)

Uploaded CPython 3.6m Windows x86-64

cbitstruct-1.0.0-cp36-cp36m-manylinux1_x86_64.whl (59.4 kB view details)

Uploaded CPython 3.6m

cbitstruct-1.0.0-cp36-cp36m-manylinux1_i686.whl (56.3 kB view details)

Uploaded CPython 3.6m

cbitstruct-1.0.0-cp36-cp36m-macosx_10_12_x86_64.whl (35.7 kB view details)

Uploaded CPython 3.6m macOS 10.12+ x86-64

cbitstruct-1.0.0-cp35-cp35m-win_amd64.whl (38.9 kB view details)

Uploaded CPython 3.5m Windows x86-64

cbitstruct-1.0.0-cp35-cp35m-manylinux1_x86_64.whl (57.9 kB view details)

Uploaded CPython 3.5m

cbitstruct-1.0.0-cp35-cp35m-manylinux1_i686.whl (55.1 kB view details)

Uploaded CPython 3.5m

cbitstruct-1.0.0-cp35-cp35m-macosx_10_12_x86_64.whl (35.2 kB view details)

Uploaded CPython 3.5m macOS 10.12+ x86-64

File details

Details for the file cbitstruct-1.0.0.tar.gz.

File metadata

  • Download URL: cbitstruct-1.0.0.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b713492c76a12b0f290e2eb34d2dfcff5e999f2332c5cbb6df1d94daa1925f7d
MD5 35e5f2df54571a6bfec498f2725816b6
BLAKE2b-256 fb9792ff77f0d225653ebf526c8787c04cf33959dd599407d15e7349453ba5c0

See more details on using hashes here.

File details

Details for the file cbitstruct-1.0.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: cbitstruct-1.0.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 39.6 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 ac13a5f9207b089ee3c46dd4bd4b04bd685637d85ce314234a9c1e7673fdb00f
MD5 102c9940b1614c569238c034f8108f82
BLAKE2b-256 30be2910f3b7ffacc95caf559d0775cb523607ead3d676089e34577f77709c44

See more details on using hashes here.

File details

Details for the file cbitstruct-1.0.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: cbitstruct-1.0.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 59.4 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7051cd5eeddb22ad89a69904148ee27804f146cd4f8155d22dbbed2ef7cf69c9
MD5 986b7fb3036989ca52bb0572a1e5e724
BLAKE2b-256 0101391295c5f1b2f1f9d5d072a1903a120608a356b56cda430656c6116d8d28

See more details on using hashes here.

File details

Details for the file cbitstruct-1.0.0-cp37-cp37m-manylinux1_i686.whl.

File metadata

  • Download URL: cbitstruct-1.0.0-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 56.4 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.0-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 4bb530fc8dbd43226bc9c8d368914e5b0f5490cc23aeb88c406b6a238a85313c
MD5 b072f693c9f8876b4d6d8fe100d803f5
BLAKE2b-256 3388271046cf44a582d77cbe35eb733e652a211db75c7e2661375ec781e37f69

See more details on using hashes here.

File details

Details for the file cbitstruct-1.0.0-cp37-cp37m-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: cbitstruct-1.0.0-cp37-cp37m-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 35.7 kB
  • Tags: CPython 3.7m, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.0-cp37-cp37m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a03d46ad3307bb0a298a6ba799b25b95c966364e2d02b8006088b2ca1972f600
MD5 c343fadee6419234d85b91817cb68de8
BLAKE2b-256 b7ec0c499e69f7bfebc8d1b2b65c6b6c7044114b4a9d8b9bfc4d4eb271aa1ed6

See more details on using hashes here.

File details

Details for the file cbitstruct-1.0.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: cbitstruct-1.0.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 39.6 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 94d2682c86865146fdddd418407e49491f5b50545499f9ac8e444197a55668b3
MD5 199f61379fbea3860b7d558c95cd3071
BLAKE2b-256 a471c2a5e1fbdaf400c9ce788ec7a941ab4bbb7f7dcfde5bb61dec205fba27b5

See more details on using hashes here.

File details

Details for the file cbitstruct-1.0.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: cbitstruct-1.0.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 59.4 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9ee5977ff1b3069ddf47c476959661c6f23d76c4fe38b403ee308ebf548fb409
MD5 6593fbaa3800708a628dd51b0661272b
BLAKE2b-256 1cd9a147b5a9fbe9a19646d3ae0b0b6a3c329fb4267b2017fded8e9b011cd990

See more details on using hashes here.

File details

Details for the file cbitstruct-1.0.0-cp36-cp36m-manylinux1_i686.whl.

File metadata

  • Download URL: cbitstruct-1.0.0-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 56.3 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 d97d308943c889d3d1e25cbae7fb4c9229cf1351decf0a3d7dd9288f933258f5
MD5 343a0954a110b60674c971db6a3f58f4
BLAKE2b-256 e83fca1dac8a489d55391658e53e8579b19b1ebf07e969d891686d7c43ad2478

See more details on using hashes here.

File details

Details for the file cbitstruct-1.0.0-cp36-cp36m-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: cbitstruct-1.0.0-cp36-cp36m-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 35.7 kB
  • Tags: CPython 3.6m, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.0-cp36-cp36m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 22f58ae885d9aee0fd39d08cd83c241167298e3fb566db8715b37e7f14ea47de
MD5 d5c94d59ef9f74931b47c394c111c84c
BLAKE2b-256 6d4e7eac70da947b9b90617c2182a2801b117345e9201087752d1122c0599478

See more details on using hashes here.

File details

Details for the file cbitstruct-1.0.0-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: cbitstruct-1.0.0-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 38.9 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 8485927b3a6637a8952c9152091272c8bc88771f9f572c0f5189d525437d5580
MD5 7ad7096fc2dc99df2abd9c72c9b3b90e
BLAKE2b-256 1bf064af2c26cc9eac833361137d803b5d78ca5caf12a13e11344ed53eed0dae

See more details on using hashes here.

File details

Details for the file cbitstruct-1.0.0-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: cbitstruct-1.0.0-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 57.9 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9c7e319ef7ed90d36dc3499dd02f0e51690e6bc0fb183fe5210f698a00bee014
MD5 dbd6d59b1408be83e03569712c53d691
BLAKE2b-256 6fcfbb4cb97fdde04494144bae83118464cae71a68637777725b087088f9fcbf

See more details on using hashes here.

File details

Details for the file cbitstruct-1.0.0-cp35-cp35m-manylinux1_i686.whl.

File metadata

  • Download URL: cbitstruct-1.0.0-cp35-cp35m-manylinux1_i686.whl
  • Upload date:
  • Size: 55.1 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 33994fd76e58f8d33f4e1308b9270156d6c54878e23d24acb7084a98f460f6a2
MD5 0a183664fd0b6cb753d7ec88f785b830
BLAKE2b-256 97886219f6d72793306096e007c1323ec345ba5a427e0ddda7e0c1cfc19da152

See more details on using hashes here.

File details

Details for the file cbitstruct-1.0.0-cp35-cp35m-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: cbitstruct-1.0.0-cp35-cp35m-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 35.2 kB
  • Tags: CPython 3.5m, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.0-cp35-cp35m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 18e702b2b145d4360399e73f6fdcfe79cb4e771c9f839db3f34e6b4e75d87a3f
MD5 af86f0f69118663e825b5626b3e60c54
BLAKE2b-256 e3f985e0e696dadfd49b15dca0cc15ea858d35a1e5bfcd98c6ea8148b7a01233

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page