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.779 (   8.638us ->   0.984us)
byteswap str              | x 17.466 (   9.158us ->   0.524us)
calcsize                  | x139.330 (  61.060us ->   0.438us)
compiled pack             | x 47.389 (  35.968us ->   0.759us)
compiled pack_dict        | x 27.184 (  34.588us ->   1.272us)
compiled pack_into        | x 32.037 (  38.650us ->   1.206us)
compiled pack_into_dict   | x 27.343 (  37.718us ->   1.379us)
compiled unpack           | x 33.928 (  31.278us ->   0.922us)
compiled unpack_dict      | x 21.627 (  31.597us ->   1.461us)
compiled unpack_from      | x 30.622 (  29.977us ->   0.979us)
compiled unpack_from_dict | x 20.479 (  30.936us ->   1.511us)
pack                      | x 77.003 ( 103.030us ->   1.338us)
pack_dict                 | x 53.254 ( 103.255us ->   1.939us)
pack_into                 | x 82.829 ( 119.373us ->   1.441us)
pack_into_dict            | x 52.173 ( 108.135us ->   2.073us)
unpack                    | x 78.459 (  91.896us ->   1.171us)
unpack_dict               | x 40.287 (  89.300us ->   2.217us)
unpack_from               | x 77.027 (  91.202us ->   1.184us)
unpack_from_dict          | x 39.467 (  88.043us ->   2.231us)

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.3.tar.gz (23.8 kB view details)

Uploaded Source

Built Distributions

cbitstruct-1.0.3-cp37-cp37m-win_amd64.whl (40.6 kB view details)

Uploaded CPython 3.7m Windows x86-64

cbitstruct-1.0.3-cp37-cp37m-manylinux1_x86_64.whl (60.7 kB view details)

Uploaded CPython 3.7m

cbitstruct-1.0.3-cp37-cp37m-manylinux1_i686.whl (57.6 kB view details)

Uploaded CPython 3.7m

cbitstruct-1.0.3-cp37-cp37m-macosx_10_12_x86_64.whl (36.8 kB view details)

Uploaded CPython 3.7m macOS 10.12+ x86-64

cbitstruct-1.0.3-cp36-cp36m-win_amd64.whl (40.6 kB view details)

Uploaded CPython 3.6m Windows x86-64

cbitstruct-1.0.3-cp36-cp36m-manylinux1_x86_64.whl (60.7 kB view details)

Uploaded CPython 3.6m

cbitstruct-1.0.3-cp36-cp36m-manylinux1_i686.whl (57.5 kB view details)

Uploaded CPython 3.6m

cbitstruct-1.0.3-cp36-cp36m-macosx_10_12_x86_64.whl (36.8 kB view details)

Uploaded CPython 3.6m macOS 10.12+ x86-64

cbitstruct-1.0.3-cp35-cp35m-win_amd64.whl (40.1 kB view details)

Uploaded CPython 3.5m Windows x86-64

cbitstruct-1.0.3-cp35-cp35m-manylinux1_x86_64.whl (59.2 kB view details)

Uploaded CPython 3.5m

cbitstruct-1.0.3-cp35-cp35m-manylinux1_i686.whl (56.3 kB view details)

Uploaded CPython 3.5m

cbitstruct-1.0.3-cp35-cp35m-macosx_10_12_x86_64.whl (36.3 kB view details)

Uploaded CPython 3.5m macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: cbitstruct-1.0.3.tar.gz
  • Upload date:
  • Size: 23.8 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.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.3.tar.gz
Algorithm Hash digest
SHA256 cf7574dc4c98c9a617291113df4a60527b7f1482252c422f8deb7bc7df656326
MD5 05bb844be90655db0c3bc7e691e8811b
BLAKE2b-256 40bc8905dd3dfea15a9ddf04748462f6665c43b05ae6e1d17edad224b2cee0bf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.3-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 40.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.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 9dbd9e2fc537f07fe2482487d38e07e441615388331ed9c70da73dde611d0a81
MD5 b066a851c8972e18b7e44b014168967b
BLAKE2b-256 4f32c91908208b4a136edda04e1f5443c2aa429cff066d365dc1c02cdf00c4b2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.3-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 60.7 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.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7db7a0e2dddf58e5b9063abc65f1b6b91e88388a9f02885b80fab7a5914db938
MD5 1c4e1a2adfac693c0357e3f51a75570b
BLAKE2b-256 9b4de07d1f0d1a108886160b852a19f4a8f83ec51161e8fd6e56d960cc963c95

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.3-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 57.6 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.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.3-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 286f07647c0aa308616850b0b12732b3715547731baa3d38bcfc359d6aca5e3e
MD5 8d56aaccc86028bc47ec9d09bafba0c5
BLAKE2b-256 296b1d517f196a525ede4937a8994047317c334c3fc8a4993956116a0bc3ea1f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.3-cp37-cp37m-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 36.8 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.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.3-cp37-cp37m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3dc2b8b79486a3c317da3c7924f158e9993ebc1eea24e8829e2129b151c796ae
MD5 a329c672a34538798706bd0052f5f107
BLAKE2b-256 1472dc256a56bb53b237a509e8fd7daeaaef8c864de5a895e838964a4d7d9b2c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.3-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 40.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.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 488f485d4d21e08cf1375a0db16133830f08223e41d8d0d957aecf255ab0209b
MD5 123088333cea23c399ed5fdbc89579c3
BLAKE2b-256 0acd679802f8a1db1b963f680cbce9afa6107d281eec115f917042b56a84c124

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.3-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 60.7 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.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0fba843674224e65ae29a571564375dd5329a61bd85e4d463cdb8fda57fee987
MD5 44409b87276cd2253aa9e4d636dedd8f
BLAKE2b-256 2d2435f218fd7cb1da03ef275272d75b6a69e5c20ed8eb75b9287c2a35c05f17

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.3-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 57.5 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.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.3-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 961b0ebb435899dcde005e1efeff9b716f2dc784eb452357c69ff5da6c9aec2d
MD5 6fc4c753710befa3ffc2a9cfaacd782f
BLAKE2b-256 3cdcbac6b91406ea9b3b2574204b365468d4d5c39a0476cb7bcf21dcf1e7e8b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.3-cp36-cp36m-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 36.8 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.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.3-cp36-cp36m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 99bf6799076ecd2caa81d8ad6b6e43c871aa1532919bb3a7957db4e813b0c978
MD5 682fc3d1263e80ad97c6921946d3fb3c
BLAKE2b-256 17fab28a43db8fbadbbf72829c8504add5676e7e279c165316eb5203041c682f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.3-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 40.1 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.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.3-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 020ec38ab6ca7f8a8899416acaf8369f936496e87b3d6e567fbc8333e68bc499
MD5 516a3412f53421c86f981692d170af32
BLAKE2b-256 33956b20321c98eda572681964978a67435429eb3ddf39d3f7d4a39dbf26e15c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.3-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 59.2 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.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.3-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 dc07c618ace80e3d72cf3199bd6d7905c787927ec5e2a157ca7a74ee471c3ce3
MD5 4bdce777964bdcc0297b47e4b3f20abc
BLAKE2b-256 58ada27f25992e7ffc28f6447f0a7b05f82bc3d9c7794b99d748f72705c17866

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.3-cp35-cp35m-manylinux1_i686.whl
  • Upload date:
  • Size: 56.3 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.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.3-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 c2f4355360d21b9a7fc395853ab4ec9486e191494af8561d84fae9dcf1f4a66b
MD5 f85bee38a08df1245c14459175660d65
BLAKE2b-256 e71f00b38d4add5a76252d48097f56e4c671f8bb679dd6e3fa26b16a8f3bdc33

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.3-cp35-cp35m-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 36.3 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.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.3-cp35-cp35m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9ce5f8ab5991e1d07b40afa62057521561d1885c3b7574e1bc5f6dc4e63e9777
MD5 8bd032baa6496b2e111ddfba281de69a
BLAKE2b-256 c66b5fd67da3c2428672cd32c7dd90ac6ea3bcd0426d8590f9a8bef292bf2c2f

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