msgspec
msgspec copied to clipboard
A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML
In #711 we added support for Python 3.13. More work is needed to add support for freethreading (and build wheels supporting it). - [ ] Add CI support - [...
### Description Imagine that I have a user being created from a web form, and it's defined like: ```python class User(Struct): first_name: str middle_name: str last_name: str username: str title:...
### Question How can I simulate abstract classes using msgspec? I know it's not the main intention of msgspec, but I really want to represent a hierarchy of classes using...
### Description Hi This library is great, well documented and well thought-out, thanks for the work you've put into it! I'm the lead maintainer of https://github.com/langchain-ai/langgraph and was considering using...
### Description When we create a tagged `array_like` struct, it is not possible to influence where the tag field is in the field order. This prevents using this feature to...
### Description Hi, Would there be any interest in adding support for numpy datatypes? Currently, attempting to encode these fails: ```python import msgspec.json as mjson import numpy as np mjson.encode(np.float64(1.0))...
### Question HI. Is it possible to dynamically create a struct from an unknown JSON schema? I mean, the user will inform me the way he wants the struct to...
### Related Issues #671 ("Support adding hooks for supported objects types") - Similar request for overriding native type handling. #766, #669, #671 --- ### Description When using `msgspec.convert` with structs,...
### Description Currently `array_like` encodes like `[MyClassName,field0,field1,...]` For small structs (with descriptive names) this can be a large part of the message. Irrespectively encoding a string as a message identifier...
Let's say `CustomType` cannot parse correctly `obj`, I would like to return `None` as it is a valid type as defined in `MyStruct`. Why is it generating a `ValidationError` ?...