- Add
to_builtins
function for converting messages composed of any supported type to ones composed of only simple builtin types commonly supported by Python serialization libraries (#258). - Add
from_builtins
function for converting and validating messages composed of simple builtin types to ones composed of any type msgspec supports (#266, #302). - Add
msgspec.yaml
module for encoding/decoding YAML (#267). - Add
msgspec.toml
module for encoding/decoding TOML (#268). - Add
msgspec.structs.replace
function for creating a copy of an existingStruct
with some changes applied (#262). - Add
msgspec.structs.asdict
andmsgspec.structs.astuple
functions for converting a struct instance to adict
ortuple
respectively (#300). - Support arbitrarily nested
typing.NewType
/typing.Annotated
types (#272). - Improve error message for invalid keyword arguments passed to
Struct.__init__
(#273). - Support
default_factory
configuration forStruct
fields (#274). - BREAKING: With the exception of empty builtin collections (
[]
,{}
,set()
,bytearray()
), mutable default values in Struct types are no longer deepcopied when used. If a different mutable default value is needed, please configure adefault_factory
instead (#274). - Improve performance of creating Structs with default parameters (#274).
- Support
typing.ClassVar
annotations ofStruct
types (#281). - Support encoding/decoding
decimal.Decimal
types (#288). - Support "abstract" type annotations like
collections.abc.MutableMapping
/typing.MutableMapping
in decoders (#290). - Support any string-like or int-like type as a
dict
key when encoding or decoding JSON (#292). - Improved performance encoding large collections in JSON and MessagePack encoders (#294, #298).