Skip to main content

Convenient bit fields for int subclasses

Project description

The missing bitfield type for Python 2 and 3.

Example

The following example illustrates possible use of bfield:

from bfield import BitField

class AX(int):
    AL = BitField(0, 8, "The lower octet")
    AH = BitField(8, 16, "The higher octet")


assert AX(0x1234).AH == 0x12
assert AX(0x1234).AL == 0x34

Caveat

Note that due to specifics of immutable ints, read-only is the best thing available. This is sufficient for decoding binary protocols and file formats.

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

bfield-0.9.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

bfield-0.9.1-py2.py3-none-any.whl (4.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file bfield-0.9.1.tar.gz.

File metadata

  • Download URL: bfield-0.9.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for bfield-0.9.1.tar.gz
Algorithm Hash digest
SHA256 3c29dd9a2130da2aff7ac326d977aeba6b533b3c3845034fd4c68744a5effa2c
MD5 24d19bc55ed6a53b921c591658d2647e
BLAKE2b-256 9bc39fa89f125a6daa4ea809e3d486066f9006a78636dd8177cbfe47f78d7572

See more details on using hashes here.

File details

Details for the file bfield-0.9.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for bfield-0.9.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fab4a1736be1900e81ba1f7ed72476ef9fac42e6e4d41266b6c537f55c907931
MD5 cfbf351bd4bdf0a2944034e354006b16
BLAKE2b-256 14a2199f043d601e094aa78760a01df3cfbe1b089d2ef42adb143bc4b7036c6b

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