Skip to content

Releases

Version 0.22.0

Choose a tag to compare

@sobolevn sobolevn released this 29 Sep 12:54
6d3443f

Version 0.22.0 (2026-09-29)

  • BREAKING: Setting gc=False on a struct type that has a weakref slot,
    whether from weakref=True or from a base class, now raises ValueError.
    On CPython 3.12 and later the weakref slot is stored in a pre-header in
    front of the instance, so releasing an instance of a gc=False type with
    that slot corrupted memory, in most builds crashing the interpreter
    outright. The combination worked on 3.10 and 3.11, and the restriction
    applies there as well, so that the same class definition behaves the same
    way on every supported version (#1207).
  • Add frozendict support on Python 3.15+ (#1052, #1105).
  • Support passing a callable as decimal_format to msgspec.json.Encoder and
    msgspec.msgpack.Encoder for custom Decimal encoding (#978).
  • Support Literal[True] and Literal[False] types (#1004).
  • Publish CPython 3.15 wheels, including freethreaded builds (#1152).
  • Publish Linux riscv64 wheels (#987).
  • Support the PyEmscripten (Pyodide) platform (#1083).
  • Fix handling of PEP 695 type parameter syntax (class Foo[T]) and of
    types.GenericAlias instances in type annotations (#962).
  • Fix NameError when creating a Struct with an unquoted forward
    reference on Python 3.14 (#1165).
  • Fix a crash on incorrect typing.ClassVar annotations (#1097).
  • Fix an AttributeError when converting to a Struct type defined in a
    namespace without a __name__ (#1072).
  • Fix overriding an inherited field alias back to the field's own name
    (#1133).
  • Raise ValidationError instead of SystemError when convert receives an
    out-of-range int for a float target (#1162).
  • Report raw rather than the misleading any as the expected type when a
    non-Raw value is given for a Raw field in convert, and therefore in
    yaml.decode and toml.decode (#1169).
  • Fix an empty expected-type name in validation errors for a required Raw
    field in a TypedDict, or a Raw field with a default_factory on a
    dataclass or an attrs class (#1176).
  • Correct the error messages for out-of-range Meta length bounds
    (#1172).
  • Fix a reference leak when decoding msgpack Ext payloads (#1109).
  • Fix backing type declaration of Ext.code (#1135).
  • Fix a reference leak in msgspec.to_builtins, and therefore in
    yaml.encode, for array_like=True structs (#1177).
  • Fix reference leaks in typenode_collect_literal, Meta.__rich_repr__,
    ms_decode_bigint, and Encoder.__init__ (#1021, #1022,
    #1023, #1040).
  • Fix msgspec.inspect.type_info and msgspec.json.schema crashing on mixed-type Literals such as Literal[1, None] (#1080).
  • Place null last in the anyOf generated for optional unions in JSON
    schemas (#1028).
  • Fix minItems in the JSON schema for array_like=True structs whose fields
    are all optional (#1124).
  • Use [] or "" rather than a Python set or bytearray object as the
    JSON schema default for Struct fields with a set or bytearray
    default_factory (#1183).
  • Preserve JSON Schema metadata and string constraints in propertyNames for
    annotated dictionary key types (#866).
  • Fix msgspec.json.encode raising TypeError for a dict keyed by a plain
    enum.Enum with str values (#1118).
  • Fix missing GC traversal and clearing of some module state members (#1060).
  • Ensure an exception is always set on allocation failures (#1044).
  • Fix compilation warnings on Python 3.15 (#1077).
  • Report the leading argument of the encode and decode functions and
    methods as positional-only in inspect.signature and the rendered docs,
    matching runtime behavior (#1116).
  • Add overloads to the Meta type stub, so type checkers reject mixing gt
    with ge or lt with le (#700).
  • Many type stub improvements and fixes (#1014, #1043, #1053,
    #1055, #1057, #1062, #1063, #1064, #1065,
    #1074, #1093, #1114, #1116, #1163, #1173,
    #1179).
  • Document the differences between msgspec.structs.asdict/astuple and
    msgspec.to_builtins (#1025).
  • Document that omit_defaults ignores fields with a custom
    default_factory (#1076).
  • Fix the msgspec.json.decode docstring to say dec_hook should raise
    NotImplementedError for unsupported types, not TypeError (#774).
  • msgspec moved to the msgspec GitHub organization;
    documentation now lives at msgspec.dev (repository
    references updated in #1045).

New Contributors

Full Changelog: 0.21.1...0.22.0

Version 0.21.1

Choose a tag to compare

@Siyet Siyet released this 12 Apr 21:33
10c9ac4
  • Fix ValidationError and DecodeError raised in dec_hook being incorrectly wrapped in another ValidationError (#1013).
  • Fix a potential NULL dereference in structmeta_get_module_ns (#1016).
  • Fix a reference leak in ms_passes_big_int_constraints (#1017).
  • Fix missing ref_template parameter in msgspec.json.schema type stub (#1002).
  • Clarify order='deterministic' encoder docstrings (#1011).
  • Add a porting guide for users migrating from orjson (#1007).

Version 0.21.0

Choose a tag to compare

@jcrist jcrist released this 08 Apr 19:47
f99dca7
  • Fix a segfault on Python 3.13+ that could occur when creating structs that contained a __dict__, instead of only using __slots__ (#960).
  • Improve type annotations for msgspec.UNSET (#975).
  • Fix hashing of decoded tuples on Python 3.14 (#980).
  • Add ref_template arg to msgspec.json.schema (#983).
  • Add missing libm linkage to some architectures (#993).
  • Fix memory leak when decoding sets (#991).
  • Add uniqueItems annotation to set/frozenset JSON schemas (#984).
  • BREAKING: Call __post_init__ from msgspec.structs.replace/copy.replace (#1000).

Version 0.20.0

Choose a tag to compare

@ofek ofek released this 24 Nov 03:44
a46a2c6
  • Support Python 3.14, including freethreaded mode (#852, #877).
  • Expose the StructMeta metaclass (#890, #927, #928, #940, #945).
  • Add msgspec.inspect.is_struct and msgspec.inspect.is_struct_type functions for checking whether an object is a msgspec.Struct-like instance or class (#950).
  • Support Windows arm64 builds (#943).
  • Enable ThinLTO on macOS aarch64 builds (#937).
  • Fix leaks of re.Pattern objects when using pattern constraints of msgspec.Meta (#899).
  • Fixed memoryview support for msgspec.msgpack (#836).
  • Fix crash when typing.TypedDict contains incorrect metadata (#853, #947).
  • Add setuptools-scm as a build dependency instead of vendoring versioneer (#905).
  • Remove support for legacy packaging builds (#907).
  • Improved the developer experience by adding the just command runner and Dev Container support (#918).

Version 0.19.0

Choose a tag to compare

@jcrist jcrist released this 27 Dec 17:07
  • Improve JSON encoding performance by up to 40% (#647).
  • Ensure tuple and frozenset default values are treated identically whether specified by value or default_factory (#653).
  • Fix memory leak of match_args in StructConfig object (#684).
  • Fix memory leak in Raw.copy() (#709).
  • Update decode signatures for PEP 688 (#740).
  • Generate __replace__ method on Struct types, for use with copy.replace (#747).
  • Fix incorrect decoding of certain > 64 bit integers (#751).
  • Call __post_init__ when converting from an object to a Struct (#752).
  • BREAKING: Expand buffer when encode_into is passed a buffer smaller than offset (#753).
  • Support Raw objects as inputs to convert (#754).
  • Error nicely when a dataclass type (instead of an instance) is passed to encode (#755).
  • Drop support for Python 3.8 (#756, #763).
  • Add support for Python 3.13 (#711).
  • Remove deprecated from_builtins (#761).
  • Support encoding any Enum type whose .value is a supported type (#757).
  • Don't fail eagerly when processing generic types with unsupported __parameters__ (#772).
  • Use eval_type_backport to backport type annotations to Python 3.9 (#773).

Version 0.18.6

Choose a tag to compare

@jcrist jcrist released this 22 Jan 04:00
0.18.6
  • Support coercing integral floats to ints when strict=False (#619).
  • Preserve leading _ when renaming fields to camel or pascal case (#620).
  • Support zero-copy decoding binary fields to a memoryview (#624).
  • Fix a bug when inheriting from the same Generic base class multiple times (#626).
  • Add an order option to all encoders for enforcing deterministic/sorted ordering when encoding. This can help provide a more consistent or human readable output (#627).
  • Support inheriting from any slots-class when defining a new Struct type with gc=False (#635).
  • Automatically infer the input field naming convention when converting non-dict mappings or arbitrary objects to Struct types in msgspec.convert (#636).

Version 0.18.5

Choose a tag to compare

@jcrist jcrist released this 13 Dec 04:03
  • Support unhashable Annotated metadata in msgspec.inspect.type_info (#566).
  • Fix bug preventing decoding dataclasses/attrs types with default values and slots=True, frozen=True (#569).
  • Support passing parametrized generic struct types to msgspec.structs.fields (#571).
  • Validate str constraints on dict keys when decoding msgpack (#577).
  • Support UUID subclasses as inputs to msgspec.convert (#592).
  • Call __eq__ from generated __ne__ if user defines manual __eq__ method on a Struct type (#593).
  • Include the Struct type in the generated hash (#595).
  • Add a cache_hash struct option (#596).
  • Fix a bug around caching of dataclass type info when dealing with subclasses of dataclasses (#599).
  • Add msgspec.structs.force_setattr (#600).
  • Support custom dict key types in JSON encoder and decoder (#602).
  • Include dict key constraints in generated JSON schema via the propertyNames field (#604).
  • Add a schema_hook for generating JSON schemas for custom types (#605).
  • Add support for Python 3.12's type aliases (#606).

Version 0.18.4

Choose a tag to compare

@jcrist jcrist released this 05 Oct 04:29
  • Resolve an issue leading to periodic segfaults when importing msgspec on CPython 3.12 (#561)

Version 0.18.3

Choose a tag to compare

@jcrist jcrist released this 03 Oct 07:10
  • Improve type annotation for Struct.__rich_repr__ (#557)
  • Add pre-built wheels for Python 3.12 (#558)

Version 0.18.2

Choose a tag to compare

@jcrist jcrist released this 26 Aug 21:00
  • Support Enum._missing_ hooks for handling unknown enum values (#532).
  • Fix JSON encoding of datetime.datetime objects with zoneinfo.ZoneInfo timezone components (#534).
  • Add support for attrs validators (#538).
  • Relax datetime/time parsing format to allow some RFC3339 extensions from ISO8601 (#539).