Msgspec

Latest version: v0.18.6

Safety actively analyzes 681881 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 5 of 6

0.7.0

- Dramatically speedup JSON string decoding, up to 2x speedup in some cases (118).
- Adds a cache for decoding short (< 32 character) ASCII dict keys. This results in up to a 40% speedup when decoding many dicts with common keys using an untyped decoder. It's still recommended to define `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).
- Adds ``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](https://jcristharif.com/msgspec/benchmarks.html#benchmark-structs) than alternative libraries (122).
- Speedup `Struct` decoding for both JSON and MessagePack, on average 20% faster (119).
- Various additional performance improvements, mostly to the JSON implementation (100, 101, 102).
- Add `defstruct` method for dynamically defining new `Struct` types at runtime (105).
- Fix ARM support and publish ARM wheels for Linux and Mac (104).
- Reduce published wheel sizes by stripping debug symbols (113).
- Fix a memory leak in ``Struct.__reduce__`` (117).
- Rename ``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).

0.6.0

- Add a new [`msgspec.Raw`](https://jcristharif.com/msgspec/usage.html#raw) type for delayed decoding of message fields / serializing already encoded fields.
- Add `omit_defaults` option to `Struct` types ([docs](https://jcristharif.com/msgspec/structs.html#omitting-default-values)). If enabled, fields containing their respective default value will be omitted from serialized message. This improves both encode and decode performance.
- Add `rename` option to `Struct` types ([docs](https://jcristharif.com/msgspec/structs.html#renaming-field-names)) 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.
- Improve performance of [`nogc=True` structs](https://jcristharif.com/msgspec/structs.html#disabling-garbage-collection-advanced). GC is now avoided in more cases, and `nogc=True` structs use 16 fewer bytes per instance. Also added a [benchmark](https://jcristharif.com/msgspec/benchmarks.html#benchmark-garbage-collection) for how `msgspec` can interact with application GC usage.
- Cache creation of [tagged union](https://jcristharif.com/msgspec/structs.html#tagged-unions) lookup tables, reducing memory usage for applications making heavy use of tagged unions.
- Support encoding and decoding `frozenset` instances
- A smattering of other performance improvements.

0.5.0

- Support [tagged unions](https://jcristharif.com/msgspec/structs.html#tagged-unions) for encoding/decoding a `Union` of `msgspec.Struct` types.
- Further improve encoding performance of `enum.Enum` by 20-30%
- Reduce overhead of calling `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.
- Rename the Struct option `asarray` to `array_like` (a breaking change)

0.4.2

- Support `Literal` string types as dict keys in JSON
- Support Python 3.10 style unions (e.g. `int | float | None`)
- Publish Python 3.10 wheels

0.4.1

- Optimize decoding of `Enum` types, ~10x faster
- Optimize decoding of `IntEnum` types, ~12 faster
- Support decoding `typing.Literal` types
- Add `nogc` option for `Struct` types, disabling the cyclic garbage collector for their instances

0.4.0

This is a major release with several large changes:

- Moved MessagePack support to the `msgspec.msgpack` submodule
- New JSON support available in `msgspec.json`
- Improved error message generation to provide full path to the mistyped values
- Renamed the `immutable` kwarg in `msgspec.Struct` to `frozen` to better match python conventions
- Renamed `EncodingError` to `EncodeError`/`DecodingError` to `DecodeError` to better match python conventions
- Improved `pyright` support, allowing more errors to be statically caught by their type checker
- Adds support for Python 3.10 pattern matching on `msgspec.Struct` types
- Adds support for decoding into `typing.Union` types (with a few restrictions)
- General performance improvements across all encoders/decoders

Page 5 of 6

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.