A sub-byte-struct-supporting Python serialization/deserialization library for Python 3.8.
Project description
bytemaker
What is it?
bytemaker
is a Python 3.8-compatible zero-dependency package for byte serialization/deserialization. Its goal is to port C bitfield functionality over to Python in version 3.8, as there are applications out there that have not made the jump to 3.9 for Windows 7 compatibility reasons.
What can you do with it?
bytemaker
gives you the following:
- A
Bits
class analogous to Python'sbytes
andbytearray
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 fromBits
(and thus can be instantiated in the same wayBits
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
, Pythonctypes
, or Python native typespytypes
. Nested serialization? No problem!
How to 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file bytemaker-0.8.1.tar.gz
.
File metadata
- Download URL: bytemaker-0.8.1.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f46d7d33e9caaf66713b8fcdf0bdda08bebeadf917687633d2fcab5cacd7319 |
|
MD5 | d13dbad325990b964e247f3d5fc63beb |
|
BLAKE2b-256 | bfac86addbf0b43818c5d9574514185a9ca8425b962630ed19a33449cef78187 |
File details
Details for the file bytemaker-0.8.1-py3-none-any.whl
.
File metadata
- Download URL: bytemaker-0.8.1-py3-none-any.whl
- Upload date:
- Size: 21.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b1b8d74766dc881c873e7cffb3cca9daf7f65f716a1b61410625e625a4f90e5 |
|
MD5 | 98e61f51cb91c04013bbb60e6255b609 |
|
BLAKE2b-256 | 896571d056ce7e9c61a14c1f299c5f49ac17c4df1af8d63d49623e4df1d1ba65 |