Show HN: Bydantic – Pydantic-style bitfields for Python

1 khusmann 0 5/13/2025, 3:55:29 PM kylehusmann.com ↗
Hi HN! I’d like to share Bydantic, a Python library for declaratively defining bitfields using Python type hints and dataclass-like field types. It automatically handles serialization and deserialization, so you can focus on structure, not boilerplate.

I built Bydantic while reverse-engineering the Bluetooth protocol used by a family of inexpensive HT radios [1]. The protocol was messy and complex, and I quickly got tired of writing ad hoc parsing and packing code. What I really wanted was something like Pydantic—but for binary data. So I made this!

Finding the right balance between expressiveness and type safety was a big challenge, especially with the limits of Python’s type hinting system. But I’m really happy with how it turned out.

It’s implemented in pure Python and so should work on MicroPython, though I haven’t tested that yet.

I’d love to hear if this might be useful in your own projects—or if there are features you wish it had. Thanks for taking a look!

[1] https://kylehusmann.com/benlink

Comments (0)

No comments yet