msgspec-serde
msgspec-serde brings together the performance and flexibility of msgspec with other
common data formats:
- Representation of gridded data via
NumPy-like arrays and views. - The cross-language and schema/IDL support of
FlatBuffers.
It can generate typed msgspec.Struct models and read-only FlatBuffers
views from .fbs schemas.
Its JSON, MessagePack, and FlatBuffers codecs also support very fast encoding/decoding of
msgspec.Struct types containing NumPy arrays (with or without a FlatBuffers schema).
For example, in the recorded benchmarks, the API encodes FlatBuffers about 20–22 times faster and decodes them into complete models about 11–13 times faster than the official Python FlatBuffers API.
Installation
In a Python 3.12 or newer environment, install the package:
python -m pip install msgspec-serde
Generating modules from IDL also requires flatc, the FlatBuffers compiler. Install it
separately and make sure flatc --version works in your shell. It is not required to:
- Import, use, and ser/de of IDL-generated modules.
- Import and use JSON/MessagePack ser/de of regular
Structcontaining NumPy arrays.
Quick start
This takes you through generating msgspec.Struct from a FlatBuffers IDL, through ser/de.
If you're interested in efficient ser/de of regular Struct with NumPy arrays, you can skip
the generation step.
Generating and subclassing msgspec.Struct from IDL
Save this schema as reading.fbs:
namespace Example;
table Reading {
name:string (required);
values:[float] (required);
}
root_type Reading;
Generate the Python module:
msgspec_flatc generate reading.fbs -o generated
This creates generated/example/reading.py. The example below subclasses
Reading to reject blank names. Save it as demo.py in the same directory as
reading.fbs:
import numpy as np
from example.reading import Reading, ReadingView
from msgspec_serde import flatbuffer, json, msgpack
class ValidatedReading(Reading):
def __post_init__(self) -> None:
if not self.name.strip():
raise ValueError("name must not be blank")
reading = ValidatedReading(
name="latency", values=np.array([1.25, 2.5], dtype=np.float32)
)
buffer = flatbuffer.encode(reading)
view = flatbuffer.decode(buffer, type=ReadingView)
print(view.name, view.values.tolist())
model = view.to_model(ValidatedReading)
assert isinstance(model, ValidatedReading)
model.values[0] = 3.0
assert view.values[0] == 1.25
encoded_json = json.encode(model)
from_json = json.decode(encoded_json, type=ValidatedReading)
assert isinstance(from_json, ValidatedReading)
encoded_msgpack = msgpack.encode(model)
from_msgpack = msgpack.decode(encoded_msgpack, type=ValidatedReading)
assert isinstance(from_msgpack, ValidatedReading)
Run it from that directory:
PYTHONPATH=generated python demo.py
The script prints latency [1.25, 2.5].
A view reads fields on demand from the serialized buffer. Numeric vectors are
read-only NumPy arrays over that buffer. Calling to_model(ValidatedReading)
copies the data into a mutable model whose arrays own their storage. To decode
directly into the subclass, use
flatbuffer.decode(buffer, type=ValidatedReading).
Pass the subclass to to_model() or the decoder to run its __post_init__()
validator when constructing the model. Lazy views do not run model validation.
Features
- Encode NumPy arrays without custom conversion hooks through the
JSON and MessagePack codecs.
Reuse
EncoderandDecoderinstances when processing many values. - Decode into application subclasses
and run their
__post_init__()validation. - Vectors of tables with a
(key)field become dictionaries in models and read-onlyTableMapmappings in views. See keyed table vectors. - Read typed nested FlatBuffers.
- Register additional dynamic payload types without changing the envelope schema.
- Generate models and views for tables, structs, enums, fixed arrays, and
unions. Schema
includestatements are supported. See supported schemas and limitations.
Benchmarks
Selected-field reads are about 1.2 times faster than the official Python FlatBuffers API in the recorded workloads. This measures reading a few fields, separately from decoding the complete model.
In the recursive 1,000-object benchmark, MessagePack encodes fastest with 16-value vectors, while FlatBuffers decodes complete models fastest. With 256-value vectors, FlatBuffers is fastest in both directions.
See benchmarks.md for charts, methodology, environment details, and reproducible commands.
Tutorial
The tutorial walks through schema generation and the generated APIs. The complete runnable example is in examples/tutorial.
Backward compatibility
We aim to keep code generated by an earlier release working with later runtimes
in the same major version. This is a goal rather than a guarantee.
Major-version mismatches raise GeneratedCodeVersionError. Code generated by a
later release may not work with an earlier runtime. See
runtime version checks and warning controls.
Metadata
Release files for msgspec-serde 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| msgspec_serde-0.1.3.tar.gz | 115.4 kB | With provenance | Details for msgspec_serde-0.1.3.tar.gz |
Built distributions (wheels)
Total release size: 12.2 MB
Release files / msgspec_serde-0.1.3.tar.gz
| Download URL | msgspec_serde-0.1.3.tar.gz |
|---|---|
| Size | 115.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c6a587ef93ef2613c8570433760ee65371e912602668606aab16c73e69d4f266
|
|
BLAKE2b-256 checksum How to use checksums |
7e402b3d6e53b6875f4a5f16a7094e3ddeab15cdd841211af08dde288aeef098
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / msgspec_serde-0.1.3-cp315-abi3.abi3t-win_amd64.whl
| Download URL | msgspec_serde-0.1.3-cp315-abi3.abi3t-win_amd64.whl |
|---|---|
| Size | 732.7 kB |
| Tags | CPython 3.15 Windows x86-64 abi3 abi3t |
|
SHA-256 checksum How to use checksums |
43f589e00771f16825ab92d9fb1fa8120394b2766b29c058bd92c532aa0c35b8
|
|
BLAKE2b-256 checksum How to use checksums |
1be0ee8f8aab1ac0fc3237d3f3275772b57ef8217a54b347b103169323ed5564
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / msgspec_serde-0.1.3-cp315-abi3.abi3t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | msgspec_serde-0.1.3-cp315-abi3.abi3t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 945.7 kB |
| Tags | CPython 3.15 Linux glibc 2.17+ x86-64 abi3 abi3t |
|
SHA-256 checksum How to use checksums |
daa941ff51be6a19b9c3152fa193e2658bd89a3305a6768796fb1446e76c6666
|
|
BLAKE2b-256 checksum How to use checksums |
acbfd97fcca7834c0dba08a02728f22875ca36584cd54ffd2d6fdeae93125a1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / msgspec_serde-0.1.3-cp315-abi3.abi3t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | msgspec_serde-0.1.3-cp315-abi3.abi3t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 921.3 kB |
| Tags | CPython 3.15 Linux glibc 2.17+ ARM64 abi3 abi3t |
|
SHA-256 checksum How to use checksums |
fb3d1077a115a6ee4b913d9ad1a046cc2b09c207cc5ca4380ac8287a7b35c12f
|
|
BLAKE2b-256 checksum How to use checksums |
e11cb57621333f7b8cce5222a3c10c90f2a541ea684c23dd25f8c0a3151329ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / msgspec_serde-0.1.3-cp315-abi3.abi3t-macosx_11_0_arm64.whl
| Download URL | msgspec_serde-0.1.3-cp315-abi3.abi3t-macosx_11_0_arm64.whl |
|---|---|
| Size | 842.2 kB |
| Tags | CPython 3.15 abi3 abi3t macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
05d29bc5e878dd146dd5b108bf0c42fa422c41cb8babcaf7f56a1c62a0e89524
|
|
BLAKE2b-256 checksum How to use checksums |
d8e3c969134454eb3464b57ee79ea6362aeb396f25ee528bf7a8e377523330d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / msgspec_serde-0.1.3-cp315-abi3.abi3t-macosx_10_12_x86_64.whl
| Download URL | msgspec_serde-0.1.3-cp315-abi3.abi3t-macosx_10_12_x86_64.whl |
|---|---|
| Size | 865.2 kB |
| Tags | CPython 3.15 abi3 abi3t macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
f869933ea6e1d23e32cc36afbddba192998e958da92f0a2f4f914ca2121086dc
|
|
BLAKE2b-256 checksum How to use checksums |
40f60ca2fe62027e8c1949eaf7c338471cf55a971e98acb1ff942e8e4c14cfd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / msgspec_serde-0.1.3-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | msgspec_serde-0.1.3-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 934.5 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
684de3595db49531a380ba8b5c63ae19d82e143adbf7b2d110f76adf87eb91cd
|
|
BLAKE2b-256 checksum How to use checksums |
c16e57e1487e77f7867963900fa41c2c5554e2ae8b78f6deb38274e6a36e3ae5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / msgspec_serde-0.1.3-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | msgspec_serde-0.1.3-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 912.1 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
dbe1ee2400fa3e649a7556bd441b66cb529e1a3cb966a7c425ffead1a2b65c2c
|
|
BLAKE2b-256 checksum How to use checksums |
a60e642d0a75fd8c3e3a1735a0450966ab73634fcc33a490d9b0c3773dfa84a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / msgspec_serde-0.1.3-cp314-cp314t-macosx_11_0_arm64.whl
| Download URL | msgspec_serde-0.1.3-cp314-cp314t-macosx_11_0_arm64.whl |
|---|---|
| Size | 831.2 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3bd5227abf72fcb6ec7fe0b1c3a8fef171131ea8b2868e79f936f85c0d355a69
|
|
BLAKE2b-256 checksum How to use checksums |
6fc265026ae802e383989f0670e849a0b2c36416b7b7f12bd34a8f5e318ea7c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / msgspec_serde-0.1.3-cp314-cp314t-macosx_10_12_x86_64.whl
| Download URL | msgspec_serde-0.1.3-cp314-cp314t-macosx_10_12_x86_64.whl |
|---|---|
| Size | 854.8 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
f68702d863e1aaacdc5e38e522d4175bdb70d85b91e0fcb86162311fbe1187dc
|
|
BLAKE2b-256 checksum How to use checksums |
77b2db2d0c96668819901b03d36f7a6b4547b4feaba30c52afdff074d894088a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / msgspec_serde-0.1.3-cp312-abi3-win_amd64.whl
| Download URL | msgspec_serde-0.1.3-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 720.8 kB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ac2fef4de81ca620b9c0a39d494945164fb3da5fd61ae84996a3e4fa8eb6eddf
|
|
BLAKE2b-256 checksum How to use checksums |
b870e93efafc07e0bdf7a932514a25221bc40a099a5fa3b6f61e8da8c691ea58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / msgspec_serde-0.1.3-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | msgspec_serde-0.1.3-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 935.4 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
3683374457c00770183597f96e5fc7dbdbf76cb0f03f4b8701090b3ba9063ed5
|
|
BLAKE2b-256 checksum How to use checksums |
046b0d3c4e3171bb1a42fc2da5be71830515bfc1c74918fa94e47810fe4582e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / msgspec_serde-0.1.3-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | msgspec_serde-0.1.3-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 912.4 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
269515e851b717ad0b62a2ff8fcdfd035a018897578839f21d8c2219e8b4f050
|
|
BLAKE2b-256 checksum How to use checksums |
5eb831257ceef1997dcdda8b48f205c0eb8f31a2d07065c49bb458abcc08c50f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / msgspec_serde-0.1.3-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | msgspec_serde-0.1.3-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 833.1 kB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
28afafb3ceebdc1b813bdfd2b783848f4949329ff4b4c3751ec4e35882088565
|
|
BLAKE2b-256 checksum How to use checksums |
ba041971e8b5fa39d5f88eeaf36e1285f0474303972998a88e0663bdbbb17d37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / msgspec_serde-0.1.3-cp312-abi3-macosx_10_12_x86_64.whl
| Download URL | msgspec_serde-0.1.3-cp312-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 856.0 kB |
| Tags | CPython 3.12 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
afd18f941cca2f1f14ba307e0da36c70268dd92c714553d62b87cc46c8c5b199
|
|
BLAKE2b-256 checksum How to use checksums |
71ef4746e37c57ef6f576d9723c0a668e28d79abd06eb6f08f69d30c832bb325
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logSecurity for msgspec-serde 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 15 files in this release have been uploaded with provenance metadata.
Attestation for msgspec_serde-0.1.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.