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

Uploaded Source

Built Distributions

cbitstruct-1.0.2-cp37-cp37m-win_amd64.whl (40.5 kB view details)

Uploaded CPython 3.7m Windows x86-64

cbitstruct-1.0.2-cp37-cp37m-manylinux1_x86_64.whl (60.5 kB view details)

Uploaded CPython 3.7m

cbitstruct-1.0.2-cp37-cp37m-manylinux1_i686.whl (57.4 kB view details)

Uploaded CPython 3.7m

cbitstruct-1.0.2-cp37-cp37m-macosx_10_12_x86_64.whl (36.7 kB view details)

Uploaded CPython 3.7m macOS 10.12+ x86-64

cbitstruct-1.0.2-cp36-cp36m-win_amd64.whl (40.5 kB view details)

Uploaded CPython 3.6m Windows x86-64

cbitstruct-1.0.2-cp36-cp36m-manylinux1_x86_64.whl (60.4 kB view details)

Uploaded CPython 3.6m

cbitstruct-1.0.2-cp36-cp36m-manylinux1_i686.whl (57.4 kB view details)

Uploaded CPython 3.6m

cbitstruct-1.0.2-cp36-cp36m-macosx_10_12_x86_64.whl (36.7 kB view details)

Uploaded CPython 3.6m macOS 10.12+ x86-64

cbitstruct-1.0.2-cp35-cp35m-win_amd64.whl (40.0 kB view details)

Uploaded CPython 3.5m Windows x86-64

cbitstruct-1.0.2-cp35-cp35m-manylinux1_x86_64.whl (59.0 kB view details)

Uploaded CPython 3.5m

cbitstruct-1.0.2-cp35-cp35m-manylinux1_i686.whl (56.2 kB view details)

Uploaded CPython 3.5m

cbitstruct-1.0.2-cp35-cp35m-macosx_10_12_x86_64.whl (36.2 kB view details)

Uploaded CPython 3.5m macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: cbitstruct-1.0.2.tar.gz
  • Upload date:
  • Size: 23.7 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.2.tar.gz
Algorithm Hash digest
SHA256 1da1225c75209be6cf9d5ce5de5dfff2694f3e5d51d1f4319512528fac19c18c
MD5 8211d13b21297117df5653fb41fec131
BLAKE2b-256 9c7d45b9c12ae88760316c801a9ecfb43aad7e9382dd0473519281059cbcca66

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 40.5 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.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 f481e813c4eec6c260deceed909d1e17a63a2210b4256be32c3f6fef8499ca4e
MD5 6e446bfdd2c68a0796f8dbd98889b918
BLAKE2b-256 0aa964c86e17816530cb5408ce0a40fd45855382eabc219be6d9a82cd12304d0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.2-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 60.5 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.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b7b70fa57756fb9a4b23619a23363a7ae915803ea7581345253fd7e3cfad03d3
MD5 244b2dd0924b11eceb7bd2f9da1668b6
BLAKE2b-256 16ca1e2f3ae1af31e20f77dfbcfad597af056ec57e9f75782e35fe4fcc8101e1

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cbitstruct-1.0.2-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 2e7def4b27f06078c9fe5e5357bf4695193b8adb512c94ee68c00f950efbd0d0
MD5 201a813b060a6a1f8282c2103b640c37
BLAKE2b-256 f53cb2e24da40749df51f696bf2cc478b4dfe30752eca9384a2a96632db48776

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cbitstruct-1.0.2-cp37-cp37m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 94dea83eb367f13b352bbaa75472bd322f1e258ade61bd03ecc220cef960821f
MD5 f66f7a606db1ad991bc9004bcd82ba52
BLAKE2b-256 0edba2750fe93104a37da32c96e26d381119e877fae9e197f64a8b6c0cc8eb63

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.2-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 40.5 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.2-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 1a944e9406eb2fa9d674792dcfa4f4fe5d6ce56de728ece8a47303240785e1e7
MD5 ce0ceea34bb4dda630660bf8a1f7917b
BLAKE2b-256 07a66fca755a4f524457c6459240ef6dbd36920b86cac5f51dce0cae432e8824

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cbitstruct-1.0.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7747cf5a5e4f83daa915186ef71b32c90138d57929d8e509dab02c1ac7c73a4e
MD5 660f7485b974092f79489dbddfc5bc3a
BLAKE2b-256 47601932f06bacf656154a9c6b0d2bf3065a5c151530f81014a3486c0cc8330e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cbitstruct-1.0.2-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 93ca98bc37909a4bc4bacb48c0667b28693438d783c74348748460b08d372466
MD5 18f0578b71e5afb42a7caa32cf623d88
BLAKE2b-256 a56c379f0312b61981da2dd038a681b6688a674ca903e64ed1ed57e450a86eb5

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cbitstruct-1.0.2-cp36-cp36m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a73c3a48418d8e8cd409db6d56893cf18c35fe7d76319b4cee1a05f6fbe85f5b
MD5 5032bc0c865b81e7414bfa2b80c671fd
BLAKE2b-256 5351d273611d3426c9eaf5171f825379581c0db55ddef0a758a516b23a9b484f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.2-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 40.0 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.2-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 2a11d7e44cd0ab7350973adcc52ec89e29cb84ea13ec049888cd5043d10d95a1
MD5 c03aeef39c7ba9e06b19ff47f03a89ce
BLAKE2b-256 3d3a852adaa9e96650c99c2851c2bda6b6845e350f514a17cf500b046094b6e2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.2-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 59.0 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.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4d01fc0920d30cac8f88f900954d672aef8df21a17617cd15b4a1e5e31b80a85
MD5 9b0ed524feb52522af6d8872e3f06437
BLAKE2b-256 a95d9fd4be00ca1e595752769bb8a3f4b17e0f3eb6cad3de21966600140c27c9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cbitstruct-1.0.2-cp35-cp35m-manylinux1_i686.whl
  • Upload date:
  • Size: 56.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.2-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 d40cbbb40c517bc62fb8122cc44f98dbf6e4ccc5034e8e13e168f9b7a977a6f9
MD5 5d310cc41555c8a5b3c506b7b0c278bb
BLAKE2b-256 2ea8a113b9e788afff9d6b6c16ec90ad8327831b45948b7deb9ead27738c0c5d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cbitstruct-1.0.2-cp35-cp35m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5f5f10624a72b736f3af1a4525180b040bb738cd3a13783d3eadf63fe57d8554
MD5 5625097f22df016f6964b6048b808fcc
BLAKE2b-256 ecf9adc49d4b78154debd898ff96f7af72ceca540145745c2dece0121baa77b3

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