I was originally going to make a big post on pydantic and how we could offer typed messages using that very very nice project despite there being a couple holdups for integration with msgpack.
However, it turns out just today an even faster and msgpack specific project was released: msgspec 🏄🏼
It claims to not only be faster then msgpack-python but also supports schema evolution and other niceties
It also has perf bumps when making multiple repeated encode/decode calls which is exactly how we're currently using msgpack inside our Channel.
Overall there looks to be no downside and we'll get typed message semantics fast and free 👍🏼
For reference, I'll leave a bunch of links I'd previously gathered regarding making pydantic work with msgpack:
TODO
I was originally going to make a big post on
pydanticand how we could offer typed messages using that very very nice project despite there being a couple holdups for integration withmsgpack.However, it turns out just today an even faster and msgpack specific project was released:
msgspec🏄🏼It claims to not only be faster then msgpack-python but also supports schema evolution and other niceties
It also has perf bumps when making multiple repeated encode/decode calls which is exactly how we're currently using
msgpackinside ourChannel.Overall there looks to be no downside and we'll get typed message semantics fast and free 👍🏼
For reference, I'll leave a bunch of links I'd previously gathered regarding making
pydanticwork withmsgpack:BaseModel.serialize()effectively which looks up a serialize method by name (eg. json, msgpack) but isn't really adding any "native feeling" support nor speed gains afaict.TODO
msgpack-pythoncustom type serializer forpydantic.BaseModelsuch that we just implicitly render with.dict()as pack time and load via `Model(**message)`` at decode time?msgspecas per the comments in Try msgspec #212trio.SocketStreamusing something liketricycle.BufferedReceiveStream; @oremanj was nice enough to provide usage:msgspecas an optional dependency if we end up liking it?