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 Movist 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

Coming soon

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 ?
Only tested on linux Probably
All types except padding are limited to 64 bits Maybe for 'raw' and 'text' types
Exceptions differ from bitstruct Probably not
Python >= 3.4 Probably not
CPython only Probably not
May not work on big-endian architectures Probably not
Out-of-range numbers in packing operations are not detected Probably not
Error messages are unclear Will never be as clear as bitstruct

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.

Note that since this library is performance oriented, I will refuse changes that degrade performance (except bugfixes).

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  7.774 (   8.634us ->   1.111us)
byteswap str              | x  8.828 (  12.992us ->   1.472us)
calcsize                  | x150.863 (  60.566us ->   0.401us)
compiled pack             | x 46.257 (  35.994us ->   0.778us)
compiled pack_dict        | x 26.440 (  34.221us ->   1.294us)
compiled pack_into        | x 35.690 (  39.932us ->   1.119us)
compiled pack_into_dict   | x 25.579 (  38.404us ->   1.501us)
compiled unpack           | x 35.285 (  32.051us ->   0.908us)
compiled unpack_dict      | x 21.984 (  32.342us ->   1.471us)
compiled unpack_from      | x 32.752 (  31.353us ->   0.957us)
compiled unpack_from_dict | x 21.354 (  32.016us ->   1.499us)
pack                      | x 84.085 ( 103.511us ->   1.231us)
pack_dict                 | x 47.052 (  92.523us ->   1.966us)
pack_into                 | x 76.317 ( 105.994us ->   1.389us)
pack_into_dict            | x 41.617 (  96.210us ->   2.312us)
unpack                    | x 85.326 (  94.035us ->   1.102us)
unpack_dict               | x 41.138 (  90.074us ->   2.190us)
unpack_from               | x 82.550 (  94.934us ->   1.150us)
unpack_from_dict          | x 40.659 (  89.523us ->   2.202us)

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

cbitstruct-0.0.1-cp37-cp37m-manylinux1_i686.whl (50.7 kB view details)

Uploaded CPython 3.7m

cbitstruct-0.0.1-cp36-cp36m-manylinux1_i686.whl (50.6 kB view details)

Uploaded CPython 3.6m

cbitstruct-0.0.1-cp35-cp35m-manylinux1_i686.whl (49.6 kB view details)

Uploaded CPython 3.5m

cbitstruct-0.0.1-cp34-cp34m-manylinux1_i686.whl (49.4 kB view details)

Uploaded CPython 3.4m

File details

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

File metadata

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

File hashes

Hashes for cbitstruct-0.0.1-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 e8fd4ae7888c76c9921f5f7baab809f3ce70098b255223d139166357e2516342
MD5 814a758ac2773f5ea0954b8d329210a6
BLAKE2b-256 c2ca22bcfa2b7e6923600df53c6a7346a9c5b0f3bb88d78d0f45964c4417e6d0

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cbitstruct-0.0.1-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 ff1a8d0870c3c82bf386c567b9285f07bd5c5b80b13e7f9d93b7644ae76b3519
MD5 bf12a6fb29cde4b0601438d9ea89184a
BLAKE2b-256 482676862311b3c8a894e2d796c8d29e1c4700bd53a8f9ada78670478250cae5

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cbitstruct-0.0.1-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 d84a8d6363c810e54339de38864c890de94ca0e5fe389d97f44b3b10870f835a
MD5 adcd43273428304f349f36f7a2a29d1d
BLAKE2b-256 4728676fa691a8d8f6e2534c8460b620698501384615659aa624bd02ca201889

See more details on using hashes here.

File details

Details for the file cbitstruct-0.0.1-cp34-cp34m-manylinux1_i686.whl.

File metadata

  • Download URL: cbitstruct-0.0.1-cp34-cp34m-manylinux1_i686.whl
  • Upload date:
  • Size: 49.4 kB
  • Tags: CPython 3.4m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for cbitstruct-0.0.1-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 cc295d09e13afe3c052cdde1f8d75c6ca73e837812b20264fc04b52c3e20b35c
MD5 27769ced510c9e4d99ae9ef1e8c7bad3
BLAKE2b-256 ca616745b9e832c4809b0b1ca1748003ccd496e62e1703db3b7f84e62d861843

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