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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.7m Windows x86-64

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

Uploaded CPython 3.7m

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

Uploaded CPython 3.7m

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

Uploaded CPython 3.6m Windows x86-64

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

Uploaded CPython 3.6m

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

Uploaded CPython 3.6m

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

Uploaded CPython 3.5m Windows x86-64

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

Uploaded CPython 3.5m

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

Uploaded CPython 3.5m

cbitstruct-1.0.5-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.5.tar.gz.

File metadata

  • Download URL: cbitstruct-1.0.5.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.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.5.tar.gz
Algorithm Hash digest
SHA256 6f6f10e2756ce16ac6acbbe22eb976b908e8f8ba05245b4c269eed24b10aa71f
MD5 ceef9705257d9dc248372a53feb0cd9d
BLAKE2b-256 4d92af25fa4cdbf063d1bd7708d8effda9cd962b25f5858bce209468712d2aa1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.5-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.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.5-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 512dd83080400de89b4f612a5d4996b228360195aaec144083313b5b8916a990
MD5 df83f8ea69b5e6147feadef2cb965300
BLAKE2b-256 eaa7686a87c1a3c39ec6be129ee0c3ff415c5399b5feef7fed2196fb6642876f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.5-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.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.5-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3323a46057831b80e86e7de13910119f177d58e7521f21573cc112e921cadfce
MD5 8daad065f7138facd7248839d8f28320
BLAKE2b-256 5093671ff91f2d7621c09a9a367216f3a6dd7214fc3ae9470aafae03de950b69

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.5-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.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.5-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 33bffc90899d395fcd486bf75552bba1324c790770179647740321343fda7b71
MD5 019efd64cbc7a251ef1a10558bdd214d
BLAKE2b-256 290c9b03bb295710024398998f0db255df55f2df76befed305f00a4cf2ca0c43

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.5-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.5-cp37-cp37m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a52a4ceabf46596d07d73dbf3229b9dfa6149ca55844a1d0ea9a0ca85721ec17
MD5 22eb11c234762c41cda5a7f25109169e
BLAKE2b-256 1ded81d629aa876101e091c1119866d95ad2358a5f3fbc35c801a96c650f67ff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.5-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.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.5-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 e0f690e764e8e7ef58a9b7385476d4ed999668ad0bb3ed1c477eb616e73b464d
MD5 14c2444babc79256583d52457d423eca
BLAKE2b-256 4b6aef9e0ff48c8bd69e3f6bced750aca0009392e28e69604efa332eaac5b4f8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.5-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.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.5-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 1c6aee287339c0f809969003a6355a7f9db65e0b72c64e2b2460682abb58d62d
MD5 e4fee2fbda9c1c67277828b1ab4a50f3
BLAKE2b-256 56fadd60d7a92d3dabdc2749bc2e03c0fbcfc63703f29843559d9a572dd4b507

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.5-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.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.5-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 d80de9156377f66d6217f80bb4f2f3c358b9ae73bb78a9a1d40ca3f43b37ac40
MD5 362e2b48afe67ecb66f10dd39878a854
BLAKE2b-256 d7af936034440916aa6f707738767cd401556ec01bb36c1ca03c678a12e282d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.5-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.5-cp36-cp36m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 573d3c91e4e8ed5b675bdc02a98e3255315e079fd61cf93f0dd3c8b563c7f388
MD5 a24de2c30ea22fb69fc263ed8c839c66
BLAKE2b-256 6cc5a903edb420dbd455ef04eae1479ff755bc697dcd25ec19e4676603f5da64

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.5-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.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4

File hashes

Hashes for cbitstruct-1.0.5-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 8116e8e1251a0cd2222f140e111854b727aa0dd50e6d52a2c18b8ec05c507e94
MD5 1c9730faddda19be8b05c976fb275b66
BLAKE2b-256 6482080b7fd28443cb8cfe2dd5e879a3966e974a8a3bebdd8af2faa6f00947f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.5-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.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.5-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 99f4c1b45d3bb7029cf4326b4f4c782d7403741b1a16febfe3928b38846b572f
MD5 c11ecad7626d7374813e0c756db946b8
BLAKE2b-256 7df2da735e66f965b4d1d8ed61a30f7960db301f128d54ca7e920f766fbf525e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.5-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.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-1.0.5-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 a83813b056134da63cfef3813017c0400c2dd4705d4c3ac81b7b5375b42151d4
MD5 c46df49555a9ea7c3b88206813412d0c
BLAKE2b-256 e9a80c05bc4d40fbe39aa33183193f8d96e06919e0b057103965fc98c63a9496

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.5-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.5-cp35-cp35m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a6ebb9e6cd18ab329ec100f4edea3ca36a31f2b11866f18d7673fe64327b6bb9
MD5 dceed65b2a8fa46d29b2af65bd68d68d
BLAKE2b-256 cc18c326860fd280e697fd175e61a24db772b6ea0fd2aa70aa78c48626d8490a

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