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

Uploaded Source

Built Distributions

cbitstruct-1.0.1-cp37-cp37m-win_amd64.whl (39.7 kB view details)

Uploaded CPython 3.7m Windows x86-64

cbitstruct-1.0.1-cp37-cp37m-manylinux1_x86_64.whl (59.8 kB view details)

Uploaded CPython 3.7m

cbitstruct-1.0.1-cp37-cp37m-manylinux1_i686.whl (56.6 kB view details)

Uploaded CPython 3.7m

cbitstruct-1.0.1-cp37-cp37m-macosx_10_12_x86_64.whl (35.9 kB view details)

Uploaded CPython 3.7m macOS 10.12+ x86-64

cbitstruct-1.0.1-cp36-cp36m-win_amd64.whl (39.7 kB view details)

Uploaded CPython 3.6m Windows x86-64

cbitstruct-1.0.1-cp36-cp36m-manylinux1_x86_64.whl (59.7 kB view details)

Uploaded CPython 3.6m

cbitstruct-1.0.1-cp36-cp36m-manylinux1_i686.whl (56.6 kB view details)

Uploaded CPython 3.6m

cbitstruct-1.0.1-cp36-cp36m-macosx_10_12_x86_64.whl (35.9 kB view details)

Uploaded CPython 3.6m macOS 10.12+ x86-64

cbitstruct-1.0.1-cp35-cp35m-win_amd64.whl (39.2 kB view details)

Uploaded CPython 3.5m Windows x86-64

cbitstruct-1.0.1-cp35-cp35m-manylinux1_x86_64.whl (58.3 kB view details)

Uploaded CPython 3.5m

cbitstruct-1.0.1-cp35-cp35m-manylinux1_i686.whl (55.3 kB view details)

Uploaded CPython 3.5m

cbitstruct-1.0.1-cp35-cp35m-macosx_10_12_x86_64.whl (35.4 kB view details)

Uploaded CPython 3.5m macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: cbitstruct-1.0.1.tar.gz
  • Upload date:
  • Size: 23.3 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.1.tar.gz
Algorithm Hash digest
SHA256 d2d69550b0b6264f45b53acb0d118e18fadc428ad97d317278998ccb85e0119d
MD5 fbe87e13bace2d048cd5cf56a1dc1147
BLAKE2b-256 0dde059e925a8c57da1a38d43c07e4ee9abd79068b7f273f09b70399b3bd439a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 39.7 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.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 ad75c8fa9fb5831fe0309415f38ce508a72a53cf2e8496d7f26b2169b8ce8a7b
MD5 71102c5cad8be5911db9bdfec43453a1
BLAKE2b-256 ae8430e0df275222e387386916d241ec6cb6a8902c0185fafb9a7d0df1a7313e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.1-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 59.8 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.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 417378f040ee2770bd4280f87b808a017a736157de03a9ddd61a19d0a7be0d61
MD5 692ccba0181b136fa6403420f7bc748a
BLAKE2b-256 4aa11f207a3a337dd4e1686dc79bbb15aca94000cc027228666389a6f464701b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cbitstruct-1.0.1-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 bcf16cacdebd7526e1230fbf40289034fc39084556beddb9681d331ddb9074a9
MD5 9705f46813634377bd127f1f5333e5ac
BLAKE2b-256 25361c6651e8710894540b1a25ed1f908e7b5fb361ec2ed2e20cc3fb484eb8bc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.1-cp37-cp37m-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 35.9 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.1-cp37-cp37m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0aff9b763e4822514264375dea8f085b5685b2a26af02c5a53c75e442fb3f40a
MD5 7201d33cf01fefc372c91ad78acf2107
BLAKE2b-256 c64e6d1e16f12649de5621c6a294c5013812e280948b3bd00d0fecdebd1e140d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 39.7 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.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 3393ebca531b8f44f502a333aa75020619ff3b96aa70a00b721fc2321cabc10d
MD5 291fe7e6ac88c67f9429b21fb0d198a4
BLAKE2b-256 c467d9597cb6c4540832f647bd1d6949ab3d00ff430596841e3d63ab18f2220f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cbitstruct-1.0.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 df37819ba2e09f952168b8bacd8fad62c7631220c20467552a3d89d4886a6e30
MD5 a8abd444159fd06fac1c1c83e68d9537
BLAKE2b-256 2e5de163d7e2d591a4dc298e0bd3c713f0024070b8e82942425a85206609489a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.1-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 56.6 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.1-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 9bba043080706a6da8e7457ae61c18c4df987e5403d19917f8a6d08a43450e9b
MD5 934cb08817ba222a70c2a16435be8ed2
BLAKE2b-256 292c2ceb5b2a6dab1bf86a7828a5f23db412962fd888f831de0e4d1deb3b7b07

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.1-cp36-cp36m-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 35.9 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.1-cp36-cp36m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4a974e8c946d6e4cc53a5f295ca798ce9467f79ab05ee791425a0a161fe5a0b1
MD5 e65994e7b411ad9b76d44aa0dccdd366
BLAKE2b-256 682b1170dbcb2988effb812373e3d5b076cb6ea10af04ad8b84cd5cb1449ccd6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.1-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 39.2 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.1-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 809280016a1faa035d794346bbfa5f1c0034633f120e99d051d6cbe00c06a803
MD5 edf40f6f30d7eaa1a7fa1d000c9f64a5
BLAKE2b-256 eed1667d1967d3daa66bd3247431114427a40694b3b28a4e0465e2831f0a8ed6

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cbitstruct-1.0.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ca3106bfba2628bc860176b210d5e170e342882f4cba4621a9242e3612617bb0
MD5 171edd01ffdafc344511e250d5200b02
BLAKE2b-256 2eed135e5aabb12026d481453ac9c81453c146a401367fbda324e0cc8ff4fa4a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cbitstruct-1.0.1-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 23dc109920a6ec40624a579745a4499c1e987e40b634830459471adf46ed0e77
MD5 2360fe4a0b3dfdeb064fcc3499aac2bd
BLAKE2b-256 919c5ea97ed5a5f5e60c3fd1e157a72e23e2291e78ff5f54f2545f55a4e6e1b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.1-cp35-cp35m-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 35.4 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.1-cp35-cp35m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0c2c432c527fb3abad291ed11b0a46245901ecc597852f99c826d3983faa9dd8
MD5 be3e8d5e9f7b5a4b01e8e623a9e8c684
BLAKE2b-256 1ae13cffefb7f505ec2a827df91e93901d694a499b32f1b4010e1a19fa0afe63

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