Skip to main content

A fast and friendly JSON/MessagePack library, with optional schema validation

Project description

github pypi conda codecov

msgspec is a fast and friendly serialization library for Python, supporting both JSON and MessagePack. It integrates well with Python’s type annotations, providing ergonomic (and performant!) schema validation.

Define your message schemas using standard Python type annotations.

>>> from typing import Optional, Set

>>> import msgspec

>>> class User(msgspec.Struct):
...     """A new type describing a User"""
...     name: str
...     groups: Set[str] = set()
...     email: Optional[str] = None

Encode messages as JSON or MessagePack.

>>> alice = User("alice", groups={"admin", "engineering"})

>>> alice
User(name='alice', groups={"admin", "engineering"}, email=None)

>>> msg = msgspec.json.encode(alice)

>>> msg
b'{"name":"alice","groups":["admin","engineering"],"email":null}'

Decode messages back into Python types (with optional schema validation).

>>> msgspec.json.decode(msg, type=User)
User(name='alice', groups={"admin", "engineering"}, email=None)

>>> msgspec.json.decode(b'{"name":"bob","groups":[123]}', type=User)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
msgspec.ValidationError: Expected `str`, got `int` - at `$.groups[0]`

msgspec is designed to be as performant as possible, while retaining some of the nicities of validation libraries like pydantic. For supported types, encoding/decoding a message with msgspec can be ~2-40x faster than alternative libraries.

https://github.com/jcrist/msgspec/raw/main/docs/source/_static/bench-1.png

See the documentation for more information.

LICENSE

New BSD. See the License File.

Project details


Download files

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

Source Distribution

msgspec-0.8.0.tar.gz (141.6 kB view details)

Uploaded Source

Built Distributions

msgspec-0.8.0-cp310-cp310-win_amd64.whl (103.6 kB view details)

Uploaded CPython 3.10 Windows x86-64

msgspec-0.8.0-cp310-cp310-musllinux_1_1_x86_64.whl (120.4 kB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

msgspec-0.8.0-cp310-cp310-musllinux_1_1_aarch64.whl (119.2 kB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ ARM64

msgspec-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (119.6 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

msgspec-0.8.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (118.5 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

msgspec-0.8.0-cp310-cp310-macosx_11_0_arm64.whl (104.0 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

msgspec-0.8.0-cp310-cp310-macosx_10_9_x86_64.whl (108.2 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

msgspec-0.8.0-cp39-cp39-win_amd64.whl (103.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

msgspec-0.8.0-cp39-cp39-musllinux_1_1_x86_64.whl (120.4 kB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

msgspec-0.8.0-cp39-cp39-musllinux_1_1_aarch64.whl (119.1 kB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ ARM64

msgspec-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (119.4 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

msgspec-0.8.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (118.3 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

msgspec-0.8.0-cp39-cp39-macosx_11_0_arm64.whl (103.9 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

msgspec-0.8.0-cp39-cp39-macosx_10_9_x86_64.whl (108.1 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

msgspec-0.8.0-cp38-cp38-win_amd64.whl (104.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

msgspec-0.8.0-cp38-cp38-musllinux_1_1_x86_64.whl (121.1 kB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

msgspec-0.8.0-cp38-cp38-musllinux_1_1_aarch64.whl (120.3 kB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ ARM64

msgspec-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (120.6 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

msgspec-0.8.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (118.9 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

msgspec-0.8.0-cp38-cp38-macosx_11_0_arm64.whl (104.5 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

msgspec-0.8.0-cp38-cp38-macosx_10_9_x86_64.whl (107.9 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

Details for the file msgspec-0.8.0.tar.gz.

File metadata

  • Download URL: msgspec-0.8.0.tar.gz
  • Upload date:
  • Size: 141.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for msgspec-0.8.0.tar.gz
Algorithm Hash digest
SHA256 51f138930e9b5818a9185ada75421373efc47cc3f42c60361d54d8ba405e6263
MD5 174291cb456a0c9ced93baef6fd420d6
BLAKE2b-256 68810049549502877585c486745ca92a8ac93858e6b15a7e85c6fc3c22ca93e9

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: msgspec-0.8.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 103.6 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for msgspec-0.8.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9738bd185352ab1ec493fe37fc9b2fe8884493b76d4b50f7599d6c909a21f38a
MD5 179bb36dc5aa11fda2af6bdc8513004e
BLAKE2b-256 e0a323e3f6eb22ebe20157351a0b72c3097a5dffbb3ed63b49c87ddc7ea9e287

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 fac3baabfc8194a9e329f3a39399052f3095de52a0c1016938976d8cabb61e59
MD5 c64381f3c5592feca71cd6ab463d676d
BLAKE2b-256 3eacadac64c157a7e7e9b7db81d694bfa9ff44b5fed5b7049b4962af634b2bc5

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp310-cp310-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp310-cp310-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 c34a47313de643355a6a704e62c208d7d670f3519c58454b4bd47a8a537a2d50
MD5 637610f3e0d2463f127d478ec560a793
BLAKE2b-256 98c86107352fe2852f5f357181d3482d30c99508b6b91fe87850e35226795964

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0ad94df3a1ba1e350d7d1c1ce845ab113376fbeec2ed56f0ccdba7f582fa6dd7
MD5 19d919d1ac86b34033c3dc2387ae7964
BLAKE2b-256 2f94089e8b01a1e9b48d6904db24fe0b942f07be6aae44088f73b92963c7da18

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ab4892c93acd0fcb0ab6ab08ec83e3bc05c7aed0d99e89fc4a2d4143a7ee3c8f
MD5 cdbc9e8d3b92ccd6794a4d8fe3277a4e
BLAKE2b-256 bd6d2eccb07ee2c47b3645b3e375851f01cfab516671ee9353a67dd3d5b70cd7

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ff70aa6234088460c1d6796f348ac95b254790d76ba37d93e168c1fc985cd66
MD5 ab7e56fcc41ce69dccb6620b83aaa75f
BLAKE2b-256 318cafcb44b090eb028ecf5307014867c155a137116d05cf5c6d3262f81c5bc0

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a67524adc1093181ac795ef22434a47496b90a43e4d9dfa9af11740319883300
MD5 f750e27c615cf2f434f8dff48f47484d
BLAKE2b-256 69d42da624d11b136e7720868dbb91013a9d616dbb873f247dd02ba5b600b209

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: msgspec-0.8.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 103.6 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for msgspec-0.8.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ebbe88d1ae44c7e875e565d9ec36fb3ea5165337e2b38bd2b29c6e75203e2033
MD5 73b9291097eb34a6d5171f2694cc3118
BLAKE2b-256 01313464caa7c04963905204c23bd6f8df23b6aa37fe1a9c251641ccb5ff881a

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp39-cp39-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 74fb15fa33452a4db7d1ce6bac6ad0b1768208c348f1ea158f981ae71af55ff1
MD5 72a234b2864a3c2ec3df1a9cd00bb277
BLAKE2b-256 fb4a4c90705fd5c37612d1b3a9b46ac8ab1c673e2e2e43d46e9fc21cbe553024

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp39-cp39-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp39-cp39-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 c6b72e14acaa9ab534ad7fb9631d885b021ce751112ab562fa4a62a1fb2d0094
MD5 550bc0097c3ab3bff81f4ee96eaa3c52
BLAKE2b-256 fe81c9cf1414e98ea5a059a71fd0bbf5e5c914afc8facd86dc4fe8b0ea80825d

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0e1c66c533570e5461fbf3ff934665b2d1a2007f15dec42a9cb94fcd6920ca1f
MD5 a895a4d8f97c042b3f5504505d1dfd66
BLAKE2b-256 e6f73a9bba4c869b17c451c2a03a96b8fef0d1b1ad0179c5834b3e235293831c

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d2f2676d7c40ec50e8fc63a0546d2f0f892fcb53f85b51c6e61d2d8985a1fe8e
MD5 2550f2f23c0ce061630939525a4521b9
BLAKE2b-256 4f7dd063aaa657381b694fc26f32299c21ffc0a00075b73ed0fb4038eed4b24c

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7df3d89615f0f213f9d269049a875120df9c66e75214f075d535662dd964c9aa
MD5 4a936154599241517668442a158d5266
BLAKE2b-256 b5bf57018e78470cda7f65ba85cbefec6d441dfa9b333369eb8a445cac216026

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3c9097308017b179c1436d6c8a983e2a541c79e1d7139eab8284ec13664fbd0a
MD5 072c94e680d0c2374a79ee592b2d9487
BLAKE2b-256 1eb1391095b206c5ae2d8fd59dbc2a02709683b223041d5e69c46a6e8cfeaac9

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: msgspec-0.8.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 104.8 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for msgspec-0.8.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e9054c9868d2a6716be96c1908cd626b5bc5512aea55ee0d2cc261082f34e881
MD5 51eb97e47c5f4f2b28bf367eff572549
BLAKE2b-256 43859d3bc9b19c3adf0b4b9670ae3c50cde3a401a2af3f5cdc0deeec5d221fee

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp38-cp38-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 15ac2cf866bb2dc48348a83cd559f0c6e4f444325a8f7710e79e194088ed5ecc
MD5 f47333ac20f1917282be46301cbc4ba3
BLAKE2b-256 174e861880a432d289ce3b028909bcf267a417b8afd9ceeffc9ebca0831e0f5c

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp38-cp38-musllinux_1_1_aarch64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp38-cp38-musllinux_1_1_aarch64.whl
Algorithm Hash digest
SHA256 79331aca3d3a84d58833bd4c6b58c962ee85e2e57dfb373fe2230c8ae244220b
MD5 d449c42d5ce9b847e40e64ce3c0daac6
BLAKE2b-256 f015217ab196004fdc47967e9c57b7721ee39554e945bab35b3a1bbd3e3e0466

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c268f9cc16cb014720543558a66957910587e6178a574cbb6c90ec04f3d0da62
MD5 f2765d42af6c46cdd61687beb74b96e1
BLAKE2b-256 09677db5641c36a4c2510bd6bf78e510a6024686184f377a655f3512e60f1107

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a287b615f788fcca0eef260e5dff8339288bc8817048903e982dab31baa888b3
MD5 4f4eff7890edcc2c708c1825423037d7
BLAKE2b-256 a13724b6abe82b709125c895137382efe24ffd794602d8942c883e3f7c7ac2d2

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 28592c238ab2d14962e7fc12b7202f536cf4927cf9ef2df7af1ecffea34f831d
MD5 904b076197b58f7e4465e3fd04eae965
BLAKE2b-256 6b8643674503c5c84acdb64f1a2f06b430808b621b0034dde714a6c88c05d652

See more details on using hashes here.

File details

Details for the file msgspec-0.8.0-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for msgspec-0.8.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 67fffdc4b102de0513e4dd2a8e23e43598a028bd15779f41b587a5254bcba2c3
MD5 16494f369fae28a6f91d7d56225b8351
BLAKE2b-256 c88c506377ad062d3dc7f2345c39b2add44d94ec4b93b78bc989dede28f20a15

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page