A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML
BSD-3-CLAUSE License
Bot releases are visible (Hide)
Published by jcrist almost 2 years ago
Published by jcrist about 2 years ago
Published by jcrist about 2 years ago
typing.TypedDict
types (#142).typing.NamedTuple
types (#161).ValidationError
(a subclass of DecodeError
) to allow differentiating between errors due to a message not matching the schema from those due to the message being invalid JSON (#155).list
/dict
(#160).typing.Optional
(#162).Published by jcrist over 2 years ago
weakref
support for Struct
types through a new weakref
configuration option (#131).Published by jcrist over 2 years ago
Struct
types when your messages have a common structure, but in cases where no type is provided decoding is now much more performant (#120, #121).order
and eq
configuration options for Struct
types, mirroring the dataclasses
options of the same name. Order comparisons for Struct types are very performant, roughly 10x to 70x faster than alternative libraries (#122).Struct
decoding for both JSON and MessagePack, on average 20% faster (#119).defstruct
method for dynamically defining new Struct
types at runtime (#105).Struct.__reduce__
(#117).nogc
struct option to gc
(a breaking change). To disable GC on a Struct instance you now want to specify gc=False
instead of nogc=True
(#124).Published by jcrist over 2 years ago
msgspec.Raw
type for delayed decoding of message fields / serializing already encoded fields.omit_defaults
option to Struct
types (docs). If enabled, fields containing their respective default value will be omitted from serialized message. This improves both encode and decode performance.rename
option to Struct
types (docs) for altering the field names used for encoding. A major use of this is supporting camelCase
JSON field names, while letting Python code use the more standard snake_case
field names.nogc=True
structs. GC is now avoided in more cases, and nogc=True
structs use 16 fewer bytes per instance. Also added a benchmark for how msgspec
can interact with application GC usage.frozenset
instancesPublished by jcrist over 2 years ago
Union
of msgspec.Struct
types.enum.Enum
by 20-30%msgspec.json.decode
/msgspec.msgpack.decode
with type=SomeStructType
. It's still faster to create a Decoder
once and call decoder.decode
multiple times, but for struct types the overhead of calling the top-level function is decreased significantly.asarray
to array_like
(a breaking change)Published by jcrist over 2 years ago
Literal
string types as dict keys in JSONint | float | None
)Published by jcrist over 2 years ago
Enum
types, ~10x fasterIntEnum
types, ~12 fastertyping.Literal
typesnogc
option for Struct
types, disabling the cyclic garbage collector for their instancesPublished by jcrist over 2 years ago
This is a major release with several large changes:
msgspec.msgpack
submodulemsgspec.json
immutable
kwarg in msgspec.Struct
to frozen
to better match python conventionsEncodingError
to EncodeError
/DecodingError
to DecodeError
to better match python conventionspyright
support, allowing more errors to be statically caught by their type checkermsgspec.Struct
typestyping.Union
types (with a few restrictions)Published by jcrist about 3 years ago
Published by jcrist over 3 years ago
Published by jcrist over 3 years ago
Encoder.encode_into
api, for encoding into an existing buffer without copyingdatetime
objectsStruct
types as hashableStruct
types as MessagePack array
objects rather than map
objects.Published by jcrist over 3 years ago
Published by jcrist over 3 years ago