msgspec-serde
On the one hand:
msgspec.Structobjects are extremely efficient and convenient replacements fordataclass; andmsgspecJSON encoders and decoders are extremely efficient.- FlatBuffers offer both extremely efficient representations of structured data, and a declaration format that allows cross-language compatibility.
On the other hand:
- FlatBuffers' Python API has extremely inefficient ser/de and an inconvenient builder pattern.
msgspecser/de of np.arrays isn't very efficient and requires encoder/decoder hooks that traverse the python/C boundary.
msgspec-serde solves these two issues. It merges the features of FlatBuffers with msgspec
and enables efficient encoding/decoding of NumPy arrays across JSON, MessagePack, and FlatBuffers
in one convenient package!
Features
- Generate typed
msgspec.Structmodels and lazy, buffer-backed views from FlatBuffers IDL.- Use
msgspec_flatctool for generating, then subclass theStructclasses to add standardmsgspecvalidation, 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.
- Use
- FAST encoding/decoding of
msgspec.Structcontaining NumPy arrays into JSON, MessagePack, and FlatBuffers through dedicatedEncoderandDecoderAPIs. - 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
GeneratedCodeVersionWarningonce 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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file msgspec_serde-0.1.0.tar.gz.
File metadata
- Download URL: msgspec_serde-0.1.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2090b876be864b8a5ff00f34303daa87520e71eee6c02601775aef6598af4fb8
|
|
| MD5 |
705d9b903203a0c17e135c90116d5b0b
|
|
| BLAKE2b-256 |
bd306f26a5d3c571f72b84a867cbe1d24729e61e5971e6197b30a3e2513eb4cb
|
Provenance
The following attestation bundles were made for msgspec_serde-0.1.0.tar.gz:
Publisher:
release.yml on ebrevdo/msgspec-serde
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
msgspec_serde-0.1.0.tar.gz -
Subject digest:
2090b876be864b8a5ff00f34303daa87520e71eee6c02601775aef6598af4fb8 - Sigstore transparency entry: 2647344046
- Sigstore integration time:
-
Permalink:
ebrevdo/msgspec-serde@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ebrevdo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file msgspec_serde-0.1.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: msgspec_serde-0.1.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 915.2 kB
- Tags: CPython 3.14t, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
360346b0d4827f8fcd94301221b5f14992fd7903d9ab5cab1cd92fa80aafe8b8
|
|
| MD5 |
5ff85780667d7d7b1a54fa8e7983c892
|
|
| BLAKE2b-256 |
9515ba3bd573046d60f9486d94140c761bc37018674f18f3399b845bb838a44e
|
Provenance
The following attestation bundles were made for msgspec_serde-0.1.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on ebrevdo/msgspec-serde
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
msgspec_serde-0.1.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
360346b0d4827f8fcd94301221b5f14992fd7903d9ab5cab1cd92fa80aafe8b8 - Sigstore transparency entry: 2647344111
- Sigstore integration time:
-
Permalink:
ebrevdo/msgspec-serde@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ebrevdo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file msgspec_serde-0.1.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: msgspec_serde-0.1.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 894.5 kB
- Tags: CPython 3.14t, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a02b85f63523d2263be5e08ff76030f154b5507603c5c2e7bec623b472769ef2
|
|
| MD5 |
e1e3caa0ef662d154c003ae1c82e5b25
|
|
| BLAKE2b-256 |
925fc2399daa80748a34fe1200c37ce6eab2a1bef4743a3f83c63681ffdc9030
|
Provenance
The following attestation bundles were made for msgspec_serde-0.1.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on ebrevdo/msgspec-serde
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
msgspec_serde-0.1.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
a02b85f63523d2263be5e08ff76030f154b5507603c5c2e7bec623b472769ef2 - Sigstore transparency entry: 2647344082
- Sigstore integration time:
-
Permalink:
ebrevdo/msgspec-serde@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ebrevdo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file msgspec_serde-0.1.0-cp314-cp314t-macosx_11_0_arm64.whl.
File metadata
- Download URL: msgspec_serde-0.1.0-cp314-cp314t-macosx_11_0_arm64.whl
- Upload date:
- Size: 812.7 kB
- Tags: CPython 3.14t, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d84f5161ea8ca3cb98b92c2c89697a4907670031d8f44d2d8120beb7b016993b
|
|
| MD5 |
6167b54bb8781bb03a8c7071bdf7688f
|
|
| BLAKE2b-256 |
066ade4e0cee7dd5c027b6ec9dc81ff2f0ba037edc5648247389874b7645ea42
|
Provenance
The following attestation bundles were made for msgspec_serde-0.1.0-cp314-cp314t-macosx_11_0_arm64.whl:
Publisher:
release.yml on ebrevdo/msgspec-serde
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
msgspec_serde-0.1.0-cp314-cp314t-macosx_11_0_arm64.whl -
Subject digest:
d84f5161ea8ca3cb98b92c2c89697a4907670031d8f44d2d8120beb7b016993b - Sigstore transparency entry: 2647344123
- Sigstore integration time:
-
Permalink:
ebrevdo/msgspec-serde@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ebrevdo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file msgspec_serde-0.1.0-cp314-cp314t-macosx_10_12_x86_64.whl.
File metadata
- Download URL: msgspec_serde-0.1.0-cp314-cp314t-macosx_10_12_x86_64.whl
- Upload date:
- Size: 834.7 kB
- Tags: CPython 3.14t, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f99c9256d36ede6f7160f6ea3eaf3353cd00f20e4adedfb84b985cc65a1b3eb
|
|
| MD5 |
6f04f27d3a3082cefe0a41c93a8e8e01
|
|
| BLAKE2b-256 |
f9d74c485cc090c9dd06a7c7a70964a698a8b66ccbba9ef9d5f2f754fca01356
|
Provenance
The following attestation bundles were made for msgspec_serde-0.1.0-cp314-cp314t-macosx_10_12_x86_64.whl:
Publisher:
release.yml on ebrevdo/msgspec-serde
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
msgspec_serde-0.1.0-cp314-cp314t-macosx_10_12_x86_64.whl -
Subject digest:
1f99c9256d36ede6f7160f6ea3eaf3353cd00f20e4adedfb84b985cc65a1b3eb - Sigstore transparency entry: 2647344087
- Sigstore integration time:
-
Permalink:
ebrevdo/msgspec-serde@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ebrevdo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file msgspec_serde-0.1.0-cp312-abi3-win_amd64.whl.
File metadata
- Download URL: msgspec_serde-0.1.0-cp312-abi3-win_amd64.whl
- Upload date:
- Size: 707.2 kB
- Tags: CPython 3.12+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b876f4bfe8efca4b940d222f00dd603c0cf253f501d917d1a11fc32c66878916
|
|
| MD5 |
4a2aa0d638cffaf9d4074d23efc1d7b2
|
|
| BLAKE2b-256 |
8f41eb99a27f4f4bf125d08284b3296d30d97e6cb4213acdcf8decec208ba52d
|
Provenance
The following attestation bundles were made for msgspec_serde-0.1.0-cp312-abi3-win_amd64.whl:
Publisher:
release.yml on ebrevdo/msgspec-serde
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
msgspec_serde-0.1.0-cp312-abi3-win_amd64.whl -
Subject digest:
b876f4bfe8efca4b940d222f00dd603c0cf253f501d917d1a11fc32c66878916 - Sigstore transparency entry: 2647344057
- Sigstore integration time:
-
Permalink:
ebrevdo/msgspec-serde@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ebrevdo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file msgspec_serde-0.1.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: msgspec_serde-0.1.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 914.6 kB
- Tags: CPython 3.12+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
063e010e925c4b03bbe8f23c52628c13bdd18abe2e627298a40145065d420eae
|
|
| MD5 |
5ca757836ff4043fb7fd8c61b1591e7e
|
|
| BLAKE2b-256 |
4d2e1dfbc3d61752d43008dd2d8ad73a91873e6e2967af030df897afcca8cd6a
|
Provenance
The following attestation bundles were made for msgspec_serde-0.1.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on ebrevdo/msgspec-serde
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
msgspec_serde-0.1.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
063e010e925c4b03bbe8f23c52628c13bdd18abe2e627298a40145065d420eae - Sigstore transparency entry: 2647344095
- Sigstore integration time:
-
Permalink:
ebrevdo/msgspec-serde@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ebrevdo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file msgspec_serde-0.1.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: msgspec_serde-0.1.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 894.6 kB
- Tags: CPython 3.12+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c850e140ff04e9d085a4f360503687ec0cfdc7f79f4345b06b157ecbfcc98f0
|
|
| MD5 |
095e683d4736f28c146efa282700ab6f
|
|
| BLAKE2b-256 |
c6bd0959a445406cfb97b809f51f9237e70ccd13fb4d30e1f10c2402c6892d30
|
Provenance
The following attestation bundles were made for msgspec_serde-0.1.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on ebrevdo/msgspec-serde
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
msgspec_serde-0.1.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
9c850e140ff04e9d085a4f360503687ec0cfdc7f79f4345b06b157ecbfcc98f0 - Sigstore transparency entry: 2647344116
- Sigstore integration time:
-
Permalink:
ebrevdo/msgspec-serde@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ebrevdo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file msgspec_serde-0.1.0-cp312-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: msgspec_serde-0.1.0-cp312-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 812.9 kB
- Tags: CPython 3.12+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33fe3bea418e696be634f40d81cbbf99f73ef9d1bc75344bd6ba656515b727d5
|
|
| MD5 |
8f4983a653a7300ada64883021f46ad9
|
|
| BLAKE2b-256 |
90eb55c0f39d472274860bf3fb62d00f3ffa232ccf83524c23c23e1f2f5fd4e5
|
Provenance
The following attestation bundles were made for msgspec_serde-0.1.0-cp312-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on ebrevdo/msgspec-serde
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
msgspec_serde-0.1.0-cp312-abi3-macosx_11_0_arm64.whl -
Subject digest:
33fe3bea418e696be634f40d81cbbf99f73ef9d1bc75344bd6ba656515b727d5 - Sigstore transparency entry: 2647344068
- Sigstore integration time:
-
Permalink:
ebrevdo/msgspec-serde@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ebrevdo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Trigger Event:
push
-
Statement type:
File details
Details for the file msgspec_serde-0.1.0-cp312-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: msgspec_serde-0.1.0-cp312-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 836.7 kB
- Tags: CPython 3.12+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37b72b4494d11a7d96db84581e29661a45cc2671a62c4b1a9aa5fcbb13ce6688
|
|
| MD5 |
80c49c0e8c94698c7991a59434c0ed80
|
|
| BLAKE2b-256 |
cc6126b4302d1c455b2be0649fbb0ab4dc45a5c0103c89ea859b36772225d8df
|
Provenance
The following attestation bundles were made for msgspec_serde-0.1.0-cp312-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on ebrevdo/msgspec-serde
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
msgspec_serde-0.1.0-cp312-abi3-macosx_10_12_x86_64.whl -
Subject digest:
37b72b4494d11a7d96db84581e29661a45cc2671a62c4b1a9aa5fcbb13ce6688 - Sigstore transparency entry: 2647344076
- Sigstore integration time:
-
Permalink:
ebrevdo/msgspec-serde@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ebrevdo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d1ca3602aeff695ef13ea5cd617348c510303e2e -
Trigger Event:
push
-
Statement type: