Skip to main content

Faster C implementation of bitstruct

Project description

License Build 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.1.2.tar.gz (30.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cbitstruct-1.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (71.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

cbitstruct-1.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (72.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

cbitstruct-1.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (71.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

cbitstruct-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (69.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

cbitstruct-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (69.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

cbitstruct-1.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (69.5 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

cbitstruct-1.1.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (68.2 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

cbitstruct-1.1.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (68.2 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: cbitstruct-1.1.2.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cbitstruct-1.1.2.tar.gz
Algorithm Hash digest
SHA256 e66639714cd11b439078f90a70a7ede39ee9cb56553099999859b268eb3aedf9
MD5 bd9abc77a51b1a9b58d5833e84eb6d6e
BLAKE2b-256 534c3673ea4c0fa58ffa6b2b2410d72ee4b3220cf24a69358b8622d6d1cc9c1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cbitstruct-1.1.2.tar.gz:

Publisher: build_and_publish.yml on qchateau/cbitstruct

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cbitstruct-1.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cbitstruct-1.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ce7cad245c45ef1be12deecba850c9f7020d20caef3aa8701e3a6d9fe5a37400
MD5 e683bec632d5bf43993fe22e02c2192b
BLAKE2b-256 adebecdc495e65c0a618871ddedc4641f9a9a518b7bf6d008792a54df840f608

See more details on using hashes here.

Provenance

The following attestation bundles were made for cbitstruct-1.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_and_publish.yml on qchateau/cbitstruct

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cbitstruct-1.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cbitstruct-1.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a5708654f896e218c8aad125b3599e022af776b2c8ed1a2fbdba513da8818963
MD5 486642a03a1f09f62e1c9674c8141caa
BLAKE2b-256 9cd8c066156cbcbf144a9c71c161b7bf213938a373d2bf628bbcf7fc6a504baa

See more details on using hashes here.

Provenance

The following attestation bundles were made for cbitstruct-1.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_and_publish.yml on qchateau/cbitstruct

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cbitstruct-1.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cbitstruct-1.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 abe8adfeca39c211c75f112eca0756b0abbe6e250f692b06bbd1e74c0427f0e1
MD5 647be29b99b1d69039b3e490265c3de9
BLAKE2b-256 39181ac07539c1c45e4850513033959ff8ec34775ee1fbf571faba5f1b2a4686

See more details on using hashes here.

Provenance

The following attestation bundles were made for cbitstruct-1.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_and_publish.yml on qchateau/cbitstruct

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cbitstruct-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cbitstruct-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aadffa958d37ad2ba8049681168d2f97620d289b49817a6c8c2bf9252c6b179b
MD5 81159e2a941dbdb5df0090613a7b3b21
BLAKE2b-256 0e0c309ead8fe4357727413881e686f3e878f07a356909f4686ab30f39bbb87e

See more details on using hashes here.

Provenance

The following attestation bundles were made for cbitstruct-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_and_publish.yml on qchateau/cbitstruct

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cbitstruct-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cbitstruct-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 02d63a43f186d47a06ef54829487d1f3e5dd4a1afac5d9da7a81744270700e55
MD5 eaf84efd17d8124ffc76dc9de17be84e
BLAKE2b-256 53f3c9295d87303ef616b2c63dfb5c51c0b1b00d980f7def3f6f672fd6e4d876

See more details on using hashes here.

Provenance

The following attestation bundles were made for cbitstruct-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_and_publish.yml on qchateau/cbitstruct

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cbitstruct-1.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cbitstruct-1.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 20ccc114068ed00ff9bdcb685ae946f00652b8d05a7599712b83b850fec4841f
MD5 1947b64a62b246e454df27fe1e5dfb64
BLAKE2b-256 86bb6a6ef6d15a340d5a93cde6be542b10169f8aa32aa692b0359fa30fa11df8

See more details on using hashes here.

Provenance

The following attestation bundles were made for cbitstruct-1.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_and_publish.yml on qchateau/cbitstruct

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cbitstruct-1.1.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cbitstruct-1.1.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bd219925dbc47cac8b9a195e8804664c032ca1acc4f62287be1ed0bfe73fe551
MD5 4eaf57dd44161c8df4633dc79683ea8f
BLAKE2b-256 a6dc858627665ab381fc8c326d388494b0512c61caffbcfae117be783bcf2df6

See more details on using hashes here.

Provenance

The following attestation bundles were made for cbitstruct-1.1.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_and_publish.yml on qchateau/cbitstruct

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cbitstruct-1.1.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for cbitstruct-1.1.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bbe6debd3bc80d110dd7cada53d072503e289cc72f8b166b7091238d1fd90c3a
MD5 59da2484a715002f6bb2bb65961f0a2f
BLAKE2b-256 54eecd33a4d10e43bfe96718546b9055e5c8fad1a3895767acf39adbcb6388c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for cbitstruct-1.1.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_and_publish.yml on qchateau/cbitstruct

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page