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

Camelized attrs #372

Open LukasKrocek opened 1 year ago

LukasKrocek commented 1 year ago

Description

Hello, I have tried new support of attrs and speed is amazing.

However for me to be able to use it in production, I need to be able to decode/encode messages with camelized fields.

Would it make sense to add such functionality or is it already somehow possible?

jcrist commented 1 year ago

This is not currently possible. I had been resistant to adding extra msgspec-specific configuration to dataclasses/attrs support in favor of asking users to use msgspec.Struct types instead. Struct types should support all the same use cases as attrs/dataclasses, but have all the extra config options, and are generally measurably faster to use. Is there a reason you can't use struct types here instead?

LukasKrocek commented 1 year ago

Our entire code base already uses attrs, we discovered your library only recently and we switched from attrs where performance is crucial.

There is also some functionality in attrs that is not yet available in msgspec that we need - generics, good integration with mypy and pycharm, maybe some more I cannot think of right now.

jcrist commented 1 year ago

There is also some functionality in attrs that is not yet available in msgspec that we need - generics, good integration with mypy and pycharm, maybe some more I cannot think of right now.

Apologies for letting this sit. Since I last responded msgspec now has:

Given this support, do you still have need for this feature with attrs? And if so, do you have a suggestion for how you'd spell this configuration?