Repository navigation
v0.1.2
Highlights
⚡ Faster records
Each record class now gets its own parse, read and build, compiled when the class is defined, so calls no longer work out on each call what the record needs. A record with a Const magic parses in 0.14 µs instead of 0.29 µs, the same as hand-written struct.unpack_from into a dataclass, and builds in 0.10 µs instead of 0.16 µs. Other record shapes are 1.2-2.6x faster, with the largest gains for records with padding or enum fields. Enum fields now decode with a member lookup instead of calling the enum. The benchmark now includes a ctypes column.
The API, results and errors are unchanged.
🐛 @dataclass(slots=True) records
Records declared with slots=True failed on every parse, because the recreated class treated init=False (constant and padding) fields as __init__ parameters. They work now.
What's Changed
- d56db7e bytestruct: Give each record its own parse, read and build (#2) (@doronz88)
- 6c111ad bytestruct: Decode enum fields with a member lookup (#2) (@doronz88)
- 87854bb bytestruct: Keep init=False fields out of init in slots=True records (#2) (@doronz88)
Full Changelog: v0.1.1...v0.1.2