Skip to content

Releases: jcrist/msgspec

Version 0.15.1

19 May 17:40
Compare
Choose a tag to compare
  • Fix a reference counting bug introduced in 0.15.0 when decoding naive (no timezone) datetime/time objects in both the msgpack and json decoders (#409).
  • Work around an upstream bug in CPython to properly support Required/NotRequired in TypedDict when __future__.annotations is enabled (#410).

Version 0.15.0

10 May 17:18
Compare
Choose a tag to compare
  • Add support for Generic Struct types (#386, #393).
  • Add support for Generic dataclasses and attrs types (#396).
  • Add support for Generic typing.TypedDict and typing.NamedTuple types (#398).
  • BREAKING: No longer normalize timezones to UTC when decoding datetime objects from JSON (#391).
  • Support decoding unhyphenated UUIDs (#392).
  • A few type annotation fixups (#383, #387).
  • Dedent docstrings for descriptions when generating JSON schemas (#397).
  • Use a variant of __qualname__ when auto-generating Struct tags rather than __name__ (#399).
  • Fix bug when handling typing.Literal types containing a literal None (#400).
  • Make all Encoder/Decoder methods threadsafe (#402).
  • BREAKING: Drop the write_buffer_size kwarg to Encoder (#402).

Version 0.14.2

20 Apr 02:19
Compare
Choose a tag to compare
  • Remove __del__ trashcan usage for structs with gc=False (#369).
  • Support overriding __setattr__ in Struct types (#376).
  • Support encoding large integers in JSON (#378).
  • Fix a memory leak when msgpack decoding variable length tuples with more than 16 elements (#380).
  • Remove JSON compatibility checks when constructing a msgspec.json.Decoder. Trying to decode messages into types that JSON doesn't support will now error at decode time, rather than when the decoder is constructed (#381).

Version 0.14.1

07 Apr 15:59
Compare
Choose a tag to compare
  • Further optimize decoding of JSON arrays into lists #363
  • Fix a bug preventing using structs configured with dict=True on Python 3.11 #365
  • Avoid preallocating large lists/tuples in the msgpack decoder #367

Version 0.14.0

02 Apr 21:00
Compare
Choose a tag to compare
  • Support encoding and decoding attrs types (#323).
  • Add repr_omit_defaults configuration option for omitting struct default values in the repr (#322).
  • Expose a struct's configuration through a __struct_config__ attribute (#328).
  • Add msgspec.structs.fields utility function for inspecting the fields configured on a Struct (#330).
  • Add a dict configuration option for adding a __dict__ attribute to a Struct (#331).
  • Allow non-struct mixins to be used with struct types (#332).
  • Fix a bug when defining both lt and gt constraints on an integer type (#335).
  • Fix a bug supporting fields defined with msgspec.field() with no arguments (#343).
  • Allow arbitrary input types to msgspec.from_builtins (#346).
  • Support decoding into subclasses of int & bytes in msgspec.from_builtins (#346).
  • Add msgspec.UNSET and msgspec.UnsetType for tracking unset fields. See the docs for more information (#350).
  • BREAKING: In the unlikely event you were using the previous msgspec.UNSET singleton to explicitly indicate no default value on struct types, you should now make use of msgspec.NODEFAULT instead (#350).
  • Improve struct type annotations now that mypy supports typing.dataclass_transform (#352).
  • Support typing.Final annotations for indicating that an object field should be treated as immutable (#354).
  • Add a name keyword option to msgspec.field for renaming a single field (#356).
  • BREAKING: The rules around class inheritance and a struct's rename option have changed. See #356 for more information.

Version 0.13.1

10 Feb 06:23
Compare
Choose a tag to compare
  • Fix a memory leak in the JSON decoder introduced in 0.13.0, caused by a reference counting bug when decoding into Struct types (#312).

Version 0.13.0

09 Feb 04:50
Compare
Choose a tag to compare
  • 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 existing Struct with some changes applied (#262).
  • Add msgspec.structs.asdict and msgspec.structs.astuple functions for converting a struct instance to a dict or tuple 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 for Struct 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 a default_factory instead (#274).
  • Improve performance of creating Structs with default parameters (#274).
  • Support typing.ClassVar annotations of Struct 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).

Version 0.12.0

05 Jan 19:26
Compare
Choose a tag to compare
  • Support encoding set and frozenset subclasses (#249).

  • Support encoding/decoding typing.NewType types (#251).

  • Allow creating a msgspec.Raw object from a str (#252).

  • Add new experimental msgspec.inspect module for inspecting type annotations. This is intended to be used for building downstream tooling based on msgspec-compatible types. See the docs for more information (#253).

  • Add new extra field to msgspec.Meta, for storing arbitrary user-defined metadata (#255).

  • Improved performance for JSON encoding strings (#256).

Version 0.11.0

19 Dec 16:44
Compare
Choose a tag to compare
  • Improve performance of constructors for Struct types when using keyword arguments (#237).

  • Support constraints on dict keys for JSON (#239).

  • Add support for keyword-only arguments in Struct types, matching the behavior of kw_only for dataclasses (#242).

  • BREAKING: Change the parameter ordering rules used by Struct types to match the behavior of dataclasses. For most users this change shouldn't break anything. However, if your struct definitions have required fields after optional fields, you'll now get an error on import. This error can be fixed by either:

    • Reordering your fields so all required fields are before all optional fields
    • Using keyword-only parameters (by passing the kw_only=True option).

    See Field Ordering for more information (#242).

  • Support encoding/decoding dictionaries with integer keys for JSON (#243).

Version 0.10.1

08 Dec 18:02
Compare
Choose a tag to compare
  • Ignore attributes with leading underscores ("_") when encoding dataclasses (#234)