Skip to main content

A sub-byte-struct-supporting Python serialization/deserialization library for Python 3.8.

Project description

python-app PEP8 docs

bytemaker

What is it?

bytemaker is a Python 3.8-compatible zero-dependency package for byte serialization/deserialization. It ports C bitfield functionality over to Python in version 3.8 through dataclass-decorated class annotations and provides a convenient Bits class.

What can you do with it?

bytemaker gives you the following:

  • A Bits class analogous to Python's bytes and bytearray classes, but for sub-byte bit quantities. Bits readily supports conversion from and to both, as well as lists and bit/octet/hex strings.
  • A set of ytypes classes, including various-sized Bit classes, various-sized Byte classes, common C types (U8, U16, U32, U64, S8, S16..., and Float16, Float32, Float64), and factories to create these and chararrays to arbitrary bitcounts. All of these can be instantiated from their respective types, derive from Bits (and thus can be instantiated in the same way Bits objects can), and can be cast into each other in additional ways as needed.
  • Support for serializing/deserializing @dataclass annotated classes, where the annotations can be ytypes, Python ctypes (c_uint8, ctypes.STRUCTURE, etc.), or Python native types pytypes (int, bool, char, float). Nested types? No problem!
  • Automagic support for handling any of the aforementioned objects via aggregate_types.to_bits_aggregate and aggregate_types.from_bits_aggregate.

How do I install it?

Run python -m pip install bytemaker.

Project intent

The main goal of the project is to ease development of projects working with compiled code (e.g. ROM hacking). As such, streaming features are currently deemphasized, although I may implement them at some later date.

Errata

At present, bytemaker assumes big-endianness (à la N64). Full support for reading from and writing to little-endian ROMs will come very soon. ctypes support currently assumes development is done on a little-endian machine. This is the vast, vast, vast majority of consumer hardware today, unless you run a bi-endian machine and have set it to big-endian mode.

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

bytemaker-0.8.2.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

bytemaker-0.8.2-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file bytemaker-0.8.2.tar.gz.

File metadata

  • Download URL: bytemaker-0.8.2.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for bytemaker-0.8.2.tar.gz
Algorithm Hash digest
SHA256 fb1094cb7b8cb8c83886db13537c7e4076167185521a0691466f7ea685e4e586
MD5 09e9a23d022cd196576fc5b89788a834
BLAKE2b-256 715113d4e4354b81d3f3f885be8fbe909ebebc8a30a3f567c2c51d5c960b77b2

See more details on using hashes here.

File details

Details for the file bytemaker-0.8.2-py3-none-any.whl.

File metadata

  • Download URL: bytemaker-0.8.2-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for bytemaker-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 91c3031df9c2b35615dda66b771c9fcacbe4985915d138d7369ac33923318fd8
MD5 4fe194c3fb73f003b1784dbc1b3b719d
BLAKE2b-256 c69f879a82e3dba2cdc7d321dfea71cab40d60aed6339ce13e26faa3ca347152

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