Skip to main content

msgspec-serde

msgspec provides fast Struct types and JSON and MessagePack codecs. FlatBuffers provides compact structured-data representations, lazy access to serialized data, and schemas for cross-language compatibility.

Each library leaves a gap in Python. The official FlatBuffers Python API serializes and deserializes very slowly in our benchmarks, and encoding requires callers to assemble objects through a builder API. msgspec needs hooks that traverse NumPy arrays across the Python/C boundary. msgspec-serde combines msgspec models with generated FlatBuffers views and encodes NumPy arrays as JSON, MessagePack, or FlatBuffers through one API.

Features

  • Generate typed msgspec.Struct models and lazy, buffer-backed views from FlatBuffers IDL.
    • Use msgspec_flatc tool for generating, then subclass the Struct classes to add standard msgspec validation, methods, etc. ser/de respects subclasses.
    • Tables with (key)-annotated fields are converted to dicts (msgspec) / Maps (views).
    • Additional attributes with special handling include (nested_flatbuffer ...), (dynamic_extension), (dynamic_flatbuffer), and (dynamic_allow). See the tutorial for more details.
  • FAST encoding/decoding of msgspec.Struct containing NumPy arrays into JSON, MessagePack, and FlatBuffers through dedicated Encoder and Decoder APIs.
  • Dynamic class encoding/decoding using registries is supported using constructed hook objects.
  • Supports tables, structs, enums, fixed arrays, unions, keyed vectors, schema includes, and typed or dynamic nested FlatBuffers.

Tutorial

See TUTORIAL.md for installation, schema generation, generated models and views, JSON and MessagePack codecs, unions, nested FlatBuffers, and dynamic payloads.

Backward compatibility

Within one major SemVer version, we try to keep Python code generated by an earlier release working with later msgspec-serde runtimes. This project is young, so backward compatibility is a goal rather than a guarantee.

Forward compatibility is not guaranteed. Code generated by a later release may not work with an earlier runtime.

Every generated module records the generator version and checks the installed runtime during import:

  • If the major versions differ in either direction, import raises GeneratedCodeVersionError.
  • If the major versions match but the runtime minor version is older, import emits GeneratedCodeVersionWarning once for that generator/runtime version pair.
  • Otherwise, import continues without a version warning. Patch-version differences do not produce a warning.

To suppress the older-runtime warning, set the process-wide flag before importing generated modules:

import msgspec_serde

msgspec_serde.warn_on_older_runtime = False

The flag does not suppress GeneratedCodeVersionError for a major-version mismatch.

Benchmarks

  • The generated API encodes about 20–22 times faster and materializes models about 11–13 times faster than the official Python FlatBuffers API in the measured workloads.
  • For the recursive numeric workload, MessagePack encodes fastest with 16-value vectors, while FlatBuffers materializes fastest. With 256-value vectors, FlatBuffers is fastest in both directions.

See benchmarks.md for charts, methodology, environment details, and reproducible commands.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

msgspec_serde-0.1.1.tar.gz (112.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

msgspec_serde-0.1.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (915.5 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64

msgspec_serde-0.1.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (894.4 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARM64

msgspec_serde-0.1.1-cp314-cp314t-macosx_11_0_arm64.whl (812.7 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

msgspec_serde-0.1.1-cp314-cp314t-macosx_10_12_x86_64.whl (834.7 kB view details)

Uploaded CPython 3.14tmacOS 10.12+ x86-64

msgspec_serde-0.1.1-cp312-abi3-win_amd64.whl (707.0 kB view details)

Uploaded CPython 3.12+Windows x86-64

msgspec_serde-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (914.8 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ x86-64

msgspec_serde-0.1.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (894.7 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

msgspec_serde-0.1.1-cp312-abi3-macosx_11_0_arm64.whl (812.9 kB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

msgspec_serde-0.1.1-cp312-abi3-macosx_10_12_x86_64.whl (836.6 kB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

Details for the file msgspec_serde-0.1.1.tar.gz.

File metadata

  • Download URL: msgspec_serde-0.1.1.tar.gz
  • Upload date:
  • Size: 112.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for msgspec_serde-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6fdf6e191233f7995a79afacf283403d426667665a1caded86b20ad9f809d30f
MD5 24f863c44e582b1a80159ab53d256512
BLAKE2b-256 d9f2fc9f3bdbc077c86166a09497a7193f74f9e0bb11bbb5a3ea126d201e991b

See more details on using hashes here.

Provenance

The following attestation bundles were made for msgspec_serde-0.1.1.tar.gz:

Publisher: release.yml on ebrevdo/msgspec-serde

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file msgspec_serde-0.1.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for msgspec_serde-0.1.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 219906fb1fbab22376ecf84214f63518195f1f5d0150a917a293bd580db00a69
MD5 97787e9417ad3a45c72352dfc0585463
BLAKE2b-256 4cbc5d8f1b062a17ada60dc90c077eddbd5d17e108c9e634ef723b9044321dd3

See more details on using hashes here.

Provenance

The following attestation bundles were made for msgspec_serde-0.1.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on ebrevdo/msgspec-serde

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file msgspec_serde-0.1.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for msgspec_serde-0.1.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 80d1e22bf06b570474e4edc070d5a442e0689773dc3e4e6db1aa0ade64f176ec
MD5 b4162c17ac7f3d4ef3ba178663dd3087
BLAKE2b-256 37d994ea383c6518e6f0199fc18de97244089b8b1ac65ff9615130eea09bb9c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for msgspec_serde-0.1.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on ebrevdo/msgspec-serde

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file msgspec_serde-0.1.1-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for msgspec_serde-0.1.1-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ce6c3fa3a89f052364617379e2ca2020c04a163d374592adbf50bb473a0fed4
MD5 fbdccf599f0857cc36f7bbdc002736bf
BLAKE2b-256 35db0c9d31a1c979c42a62539b15ae3f8fa331ce6d2474688d4a76ba15173f49

See more details on using hashes here.

Provenance

The following attestation bundles were made for msgspec_serde-0.1.1-cp314-cp314t-macosx_11_0_arm64.whl:

Publisher: release.yml on ebrevdo/msgspec-serde

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file msgspec_serde-0.1.1-cp314-cp314t-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for msgspec_serde-0.1.1-cp314-cp314t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 cec071b56bff2e7e4af0e8845f28894bbc1f0339f81f9d671bac71d9f27cb6e2
MD5 bdbf4a3fdb2f2ba9fd4cc738c0b1f6f5
BLAKE2b-256 06fc4c90a7c4deeb754c9c017b61c7a9e69cb691dc2b71c9bc3990630427e125

See more details on using hashes here.

Provenance

The following attestation bundles were made for msgspec_serde-0.1.1-cp314-cp314t-macosx_10_12_x86_64.whl:

Publisher: release.yml on ebrevdo/msgspec-serde

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file msgspec_serde-0.1.1-cp312-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for msgspec_serde-0.1.1-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6f75ec444d0e4a9b91c2ee32065e649a0ac4eec13aa2b999fe9b5a4bea710d0a
MD5 77c3bb01dbf4491c6009c06c43e7bd54
BLAKE2b-256 8b6edac342c57e633b060f26f0915b7364018b20d868ad53ed67021158f6d2b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for msgspec_serde-0.1.1-cp312-abi3-win_amd64.whl:

Publisher: release.yml on ebrevdo/msgspec-serde

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file msgspec_serde-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for msgspec_serde-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4c52fea9589017d24d839731976f6edec6e9900eb62121c9673f987e84195370
MD5 0c9cd47e0b86a45bf07ab8ab49bdc651
BLAKE2b-256 49a192a7e4c2dc46e2a8697a47547363e51311bbe68c8a948666857e2faa5759

See more details on using hashes here.

Provenance

The following attestation bundles were made for msgspec_serde-0.1.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on ebrevdo/msgspec-serde

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file msgspec_serde-0.1.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for msgspec_serde-0.1.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ece6043091c562a32e7559a5874cb9c3376095cf63eb97356275868951bfe9ac
MD5 9e9b9d8186cc8692950f9b7bbf04f126
BLAKE2b-256 dc555b3cdda9249306492b547fba1ab2497af99dd4b8c5608f8b4cbc69983d2c

See more details on using hashes here.

Provenance

The following attestation bundles were made for msgspec_serde-0.1.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on ebrevdo/msgspec-serde

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file msgspec_serde-0.1.1-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for msgspec_serde-0.1.1-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3c80b2c8b502458b39f4826d82244ef9a8c1cc69fd85d4191b6fb9b0370619d8
MD5 86387e11a9362eae59bf8a694f5bf650
BLAKE2b-256 d7be4331225d4204f5e34980b558582ee4677bb67e1003a62a8c55840ccb9ddb

See more details on using hashes here.

Provenance

The following attestation bundles were made for msgspec_serde-0.1.1-cp312-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on ebrevdo/msgspec-serde

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file msgspec_serde-0.1.1-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for msgspec_serde-0.1.1-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7d9a5eeadbba2001736361c7f169026698ee6a20392a6a1ed338d89672b7f7d1
MD5 15669ac7fee193f08d9451721ac98b63
BLAKE2b-256 4b73bd77589625bb60faf86ddaf658a5fd4f39ee805ae8df81616a7b7bcdc027

See more details on using hashes here.

Provenance

The following attestation bundles were made for msgspec_serde-0.1.1-cp312-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on ebrevdo/msgspec-serde

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.1 This release

10 files

0.1.0

10 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page