Consider using msgspec library for structured message serialization
- Dominant language
- Python
- Stars
- 72
- Forks
- 84
- Avg merge
- 5h 11m
- Merged PRs (30d)
- 1
Description
Today I stumbled upon this library for doing json encoding/decoding in Python. Rewriting our message handling to use it could have many benefits, most importantly making it easier to document what the message format actually looks like as each message would become a class with explicit fields.
The Library: https://github.com/jcrist/msgspec
Features we need that it has:
- Supports tagged unions.
*This is how our message format currently distinguishes between commands.*
- Supports skipping serialization of default values.
*We currently filter out `None` values in a few places by copying the message before serializing it. Having this feature built in could make the code simpler and improve performance. We would just need to see how we want to handle this with non-None default values.*
- Can encode into bytearrays:
*This can make appending the newline we need more efficient*
Other features:
- Supports msgpack
*Maybe a plus? I recall there was an attempt to use msgpack before because it can be a more efficient representation than JSON, however, using inefficient representations hasn't really been a problem for us in the past (see QDataStreamProtocol :P)
Contributor guide
Assessment
This issue has not been assessed yet.