jcrist / msgspec

A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML
https://jcristharif.com/msgspec/
BSD 3-Clause "New" or "Revised" License
2.36k stars 72 forks source link

protobuf support #715

Open makarr opened 2 months ago

makarr commented 2 months ago

I'm using msgspec to shuttle data around where I'm often both the server and the client, meaning the schema is predefined and protobuf's extra compression would be nice. Taking a look at the protobuf Python library, msgspec sure looks a lot more friendly and it seems all that stuff could be handled with msgspec's pre-existing encoder / decoder hooks. It would be amazing to simply drop-in msgspec.protobuf.encode() for msgspec.msgpack.encode().

trim21 commented 1 month ago

Serialized Protobuf bytes doesn't contain scheme data, is it even possible to decode protobuf bytes without source proto file?

pablospe commented 1 month ago

Maybe relevant. The following project generates Pydantic models from protobuf: https://github.com/danielgtaylor/python-betterproto?tab=readme-ov-file#generating-pydantic-models

I think the support has to be added there instead?