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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.7m Windows x86-64

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

Uploaded CPython 3.7m

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

Uploaded CPython 3.7m

cbitstruct-1.0.4-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.4-cp36-cp36m-win_amd64.whl (40.6 kB view details)

Uploaded CPython 3.6m Windows x86-64

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

Uploaded CPython 3.6m

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

Uploaded CPython 3.6m

cbitstruct-1.0.4-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.4-cp35-cp35m-win_amd64.whl (40.1 kB view details)

Uploaded CPython 3.5m Windows x86-64

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

Uploaded CPython 3.5m

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

Uploaded CPython 3.5m

cbitstruct-1.0.4-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.4.tar.gz.

File metadata

  • Download URL: cbitstruct-1.0.4.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.4.tar.gz
Algorithm Hash digest
SHA256 cdbd3204e28a0c93c08cdd4792d13685eaa40afdbc31bb3bd1be8cc667a76db3
MD5 9430a07c8c332dbc7c676625d0d6eca3
BLAKE2b-256 268cd1af3e56e244a0afdac8033cc796c7aefa3d7a28ed34b679371fc1100a5c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.4-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/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 bdfc844b8c0bfa256fe49c461a09d883ad17fb0f1735e0eb3cb08ac349cb1fcc
MD5 5fee33a625166741d9918b3cb3162a5f
BLAKE2b-256 d0053b08aa1bd6eeeb39ffe7970ff572675b6e244a48a949ad193b77831953bd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.4-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 60.7 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.4-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 11daa19e16b8785d8e45f3adfe1cb34443c70738eef617d3f77b3c451ef74354
MD5 dba7642a7f43b5b1f9bb4d8c56d35c42
BLAKE2b-256 a8c3ed6bc404b5dcd4fd86bc752ee8b722ef65954ce88aa1dad5875ba8bbbdc2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.4-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 57.6 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.4-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 e88c3ea27ce15b14d21a2d51fef8f7280897d1f916c634dafa4933dfa7a3fdfa
MD5 ef58cfee2f3cdec6e75f3486bd8d92b6
BLAKE2b-256 e9ea7de8c5b0223e68f05b667a26df25317fc6712e84b92ae5c5268788fdc694

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.4-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/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.4-cp37-cp37m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b63a8667da9559e81cee0bb84e35784755f3836d3324725cdab219937c122f95
MD5 981e6c18310cacafee0b74b99f2c4778
BLAKE2b-256 2d0f1cc793a46032002b1be8834dca90f9caf79514e9cab3d48311797a822037

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.4-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/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 48e797ac99ddc787a7eb3cfcca47976b6c07d79ac9a99f93b2fa7638cfd7a0f0
MD5 f5b892be753b8e543950daf516bae1a6
BLAKE2b-256 1cc10c4941b70d219518f5f2492388d94f582ef1830f3cdb7357bfea260a0118

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.4-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 60.7 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.4-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 048e928788d38a448af7dd3f005df524d77abb1ad4235b7f3fdff9a118571d24
MD5 8118dd31bc7feb938ab3fc6182a02223
BLAKE2b-256 5440c3a5a2f0e126dcc3225e70f5b95976b737e5967af85646816fe3a46afc5b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.4-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 57.5 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.4-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 b2d5a23b8d1d865f16e8bdc08be1acdf761e5954e8ade941704e13b36bd31ad8
MD5 1b4aa1b5e723d5f7b1464b8cf0e5420b
BLAKE2b-256 cd7c5d8001edd8fae3ce603058f225596ee8ea2fdaf7bf3400d034c91e683f16

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.4-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/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.4-cp36-cp36m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9521d225154f3e0116690ee7a5a3f2deb86a6dbd7ab12609c06e06f97733e349
MD5 f04ba495d3c951c81146332f85ecc8e7
BLAKE2b-256 8f7f13139c6df50f6e066bf35791c3f4165878113a3cd4c3a42bffd3a2a2e0ba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.4-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/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.4-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 3e919dc6025ad44b317918caec3944cd5d99f1d85f923756f508a9c9d7f93875
MD5 f26d7fe18350ba8410ea138962cf708d
BLAKE2b-256 05715dbf6d6008e65ce6788e5bb80d9cd7a21fd3a23235d9a5517bc98f566abc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.4-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 59.2 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.4-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d1f3dcd386dd3d25eb45d3dd38e11bc663f1af04ce943a41110ee35e38be22d3
MD5 c4a146d803e2dbf7dcbc084cc3abfc6f
BLAKE2b-256 c0adc9bfe85d0741a4eba6b5a480a98fec6e9bd947291d487ca6f0c26f18c588

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.4-cp35-cp35m-manylinux1_i686.whl
  • Upload date:
  • Size: 56.3 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.4-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 20387fd9b0d19e3d830d9327b332753aead81d10806133612fb8bb934e41edde
MD5 95b8c4cf6a7c994b05e578a087a8531a
BLAKE2b-256 67e0913ec39c42ffdacafbc3cc9cfbd35af19cb1d7d9ba429fe4552a9333272e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.4-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/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.4-cp35-cp35m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 cc82e31e6bf1c4113546ab0995d8ccb3f40b44d457d07ccd6cf21316979cb3c3
MD5 b5b62e96343234350564ff75dea4714a
BLAKE2b-256 9cf65455d0ef456941186fe77d2182ec5699380d54375a8f8ea0317dfc32bdaf

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