Skip to main content

Fast and friendly msgpack (de)serialization, with type validation

Project description

github pypi

msgspec is a fast and friendly implementation of the MessagePack (msgpack) protocol for Python 3.8+. In addition to serialization/deserialization, it supports message validation using schemas defined via Python’s type annotations.

from typing import Optional, List
import msgspec

# Define a schema for a `User` type
class User(msgspec.Struct):
    name: str
    groups: List[str] = []
    email: Optional[str] = None

# Create a `User` object
alice = User("alice", groups=["admin", "engineering"])

# Serialize `alice` to `bytes` using the MessagePack protocol
serialized_data = msgspec.encode(alice)

# Deserialize and validate the message as a User type
user = msgspec.decode(serialized_data, type=User)

assert user == alice

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

https://github.com/jcrist/msgspec/raw/master/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.3.1.tar.gz (49.9 kB view details)

Uploaded Source

Built Distributions

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

msgspec-0.3.1-cp39-cp39-win_amd64.whl (71.0 kB view details)

Uploaded CPython 3.9Windows x86-64

msgspec-0.3.1-cp39-cp39-manylinux2010_x86_64.whl (196.8 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.12+ x86-64

msgspec-0.3.1-cp39-cp39-manylinux1_x86_64.whl (196.8 kB view details)

Uploaded CPython 3.9

msgspec-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl (67.3 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

msgspec-0.3.1-cp38-cp38-win_amd64.whl (70.7 kB view details)

Uploaded CPython 3.8Windows x86-64

msgspec-0.3.1-cp38-cp38-manylinux2010_x86_64.whl (196.0 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

msgspec-0.3.1-cp38-cp38-manylinux1_x86_64.whl (196.0 kB view details)

Uploaded CPython 3.8

msgspec-0.3.1-cp38-cp38-macosx_10_9_x86_64.whl (67.2 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: msgspec-0.3.1.tar.gz
  • Upload date:
  • Size: 49.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for msgspec-0.3.1.tar.gz
Algorithm Hash digest
SHA256 b12ae33b0bcbf8d69f7f5c74550e2ea0fe9885ef24bbc0b01ecd9ce1edf9c37b
MD5 93e38d7ee3ef3efbaf4102f28523c3e5
BLAKE2b-256 31633d0f8e0267bcd99579792109406026bf13d61c1665a1cc6500111b69c990

See more details on using hashes here.

File details

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

File metadata

  • Download URL: msgspec-0.3.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 71.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for msgspec-0.3.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 07bc3e4783fe3ac6bd6bf3bee8d962f121b5ee572588ad015a7738f57be1afa9
MD5 d51edd9feb4f43746cade243b404f925
BLAKE2b-256 6bed56f136f04868283cb57b02a4e2a2b6b0d0e7c18e59afecad4a8c40ec0455

See more details on using hashes here.

File details

Details for the file msgspec-0.3.1-cp39-cp39-manylinux2010_x86_64.whl.

File metadata

  • Download URL: msgspec-0.3.1-cp39-cp39-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 196.8 kB
  • Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for msgspec-0.3.1-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 427cf2fbce30492fc8e63d265dfc79092d1fef5a49c8b6215d62bec769c784b1
MD5 824151cba978128965a7f66936e9e22a
BLAKE2b-256 94c1e4b2d696024edf10bd10c9c77bfad42448cef08d174595cf9f1baf91ec01

See more details on using hashes here.

File details

Details for the file msgspec-0.3.1-cp39-cp39-manylinux1_x86_64.whl.

File metadata

  • Download URL: msgspec-0.3.1-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 196.8 kB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for msgspec-0.3.1-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 64a162db72c566c4dd841f8e7fa12b67a1f1e05795cb05233db538829edb5e6d
MD5 304c3154b7fd1ed9f6f9ce810d503bd9
BLAKE2b-256 838c27b5f44852b7d1debea6e9d796dd70d3d97c4320fe3f1ecd56f80234a35c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: msgspec-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 67.3 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for msgspec-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 240b409a37847e735d0a409217e2ca1a2b3f1703fdee923610b9216a41ba0d21
MD5 1c5e6603a2afb492220ced88f4f3f522
BLAKE2b-256 9c7fe50fe8c28ce705395e9ee2ad8f94a2dc58d6f5dca2b3261ad2f4a8bc3880

See more details on using hashes here.

File details

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

File metadata

  • Download URL: msgspec-0.3.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 70.7 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for msgspec-0.3.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 4b9c64945381ceb69fe9f32cb4a0a55cb693bccfca2b5597cf9bab50310ecdfd
MD5 9916798093f58d44129d62feb48e1e1f
BLAKE2b-256 63685c08fc398582cb164b89be50ec4d5c0d23322a9fe003fbe9fcf50b96a3ef

See more details on using hashes here.

File details

Details for the file msgspec-0.3.1-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: msgspec-0.3.1-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 196.0 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for msgspec-0.3.1-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 ffbe371bd96c57664d36b5a7ba04de41779e23d993fbe2e7279bb07e946864bd
MD5 fb67c2b8bcbcc2455be16d61015c6cc8
BLAKE2b-256 26d228f326508a4a0db6fb66c52d4516dc1268f5e22d65c7fb093feaa1c8c473

See more details on using hashes here.

File details

Details for the file msgspec-0.3.1-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: msgspec-0.3.1-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 196.0 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for msgspec-0.3.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3413bc40c1f096a668dd4c73e61dede9946812e80d140163d9da04cae520dbce
MD5 80050667ac39df21bb85e98ac04e94b8
BLAKE2b-256 093a3188057367f60778ab21e97d256eb9263121bfd91498d624f148f997608c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: msgspec-0.3.1-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 67.2 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for msgspec-0.3.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c64a75c1a2357a13acb20ed088f63518f43a15cbcf4c4c612328e88c2f223f4a
MD5 548fb920e2329331ad3a11edf9b9a930
BLAKE2b-256 755f3d683c8ca37c0a83dbaa11dceb36202911b80a56c6ecef1ce73cc8cdd521

See more details on using hashes here.

Supported by

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