Skip to main content

Typed message serialization

Project description

github pypi

msgspec is a fast and friendly implementation of the MessagePack protocol for Python 3.8+. In addition to serialization/deserialization, it supports runtime 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.Decoder(User).decode(serialized_data)

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.2.0.tar.gz (40.9 kB view details)

Uploaded Source

Built Distributions

msgspec-0.2.0-cp39-cp39-win_amd64.whl (54.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

msgspec-0.2.0-cp39-cp39-manylinux2010_x86_64.whl (145.2 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

msgspec-0.2.0-cp39-cp39-manylinux1_x86_64.whl (145.2 kB view details)

Uploaded CPython 3.9

msgspec-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl (48.0 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

msgspec-0.2.0-cp38-cp38-win_amd64.whl (54.0 kB view details)

Uploaded CPython 3.8 Windows x86-64

msgspec-0.2.0-cp38-cp38-manylinux2010_x86_64.whl (147.2 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

msgspec-0.2.0-cp38-cp38-manylinux1_x86_64.whl (147.2 kB view details)

Uploaded CPython 3.8

msgspec-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl (48.0 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: msgspec-0.2.0.tar.gz
  • Upload date:
  • Size: 40.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for msgspec-0.2.0.tar.gz
Algorithm Hash digest
SHA256 831d4d98e064fc63dba378e4aedf686eeb272218eaa8f099b76878104f620a4d
MD5 ae5387e7682a1071482bdb847be04866
BLAKE2b-256 8e86b0fcbf0884545b165d5cf8c71ed7c729d4aff67d95d948bddc0875cf7b6c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: msgspec-0.2.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 54.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for msgspec-0.2.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3aead3ef0bc7b439b21ba18078d52a8755140a2fb59ff337ba8143316728ffd7
MD5 41b8bcc170e6f94f579dc31a42721be5
BLAKE2b-256 9b49e4ddbf482b9727fcadf7a55e602fa1b649ab588e416df2aa6279cc95eb30

See more details on using hashes here.

File details

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

File metadata

  • Download URL: msgspec-0.2.0-cp39-cp39-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 145.2 kB
  • Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for msgspec-0.2.0-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 4889b1e8f24ac28bd3290ecd24216952d344e702ca35d7a56cefe667c6296eeb
MD5 56cea9116bb64442203f8eeb2a881a2e
BLAKE2b-256 c0b0324adde174a6c5186467f6639a76b46c382eb7e176dbb80fd36354878bc2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: msgspec-0.2.0-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 145.2 kB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for msgspec-0.2.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 eebdbae479d2e3a9601738fecbbe0eead2ae5b17b699bf753658c820ea5060a9
MD5 b6f1560cb9513a838636baa2e6fbbd35
BLAKE2b-256 0405ce2a6c22e8d40407ad5ea33500addbcce47afe1a11b8dc7a22bd2c06d38f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: msgspec-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 48.0 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for msgspec-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c84e2e92ada187fce9882585a271f248974bb816dd779fe32c66967f6b3f5cc1
MD5 6daef762185fea6f7523ce5f07f75e54
BLAKE2b-256 fb64861739b20777ecf658e11192e67ca68dfe54d027a6c6fbf0bca16aeb082a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: msgspec-0.2.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 54.0 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for msgspec-0.2.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 07b685ee1513f3e1fe63540fd670dae6ce4ec084fa4fd6ffeb31b4ddc6c9d8d1
MD5 dcbc48168b4f6e5a55b4e1bd95392e1c
BLAKE2b-256 9853e35814fd28f4ce9a399101e3cdcec22eaa3b81ba126cd5622b07bfe3ca93

See more details on using hashes here.

File details

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

File metadata

  • Download URL: msgspec-0.2.0-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 147.2 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for msgspec-0.2.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 37e26a88de26dfd47090f9ef44e9787b488f370f4321e5e6e9ad052a46948b75
MD5 0d7a4c555932902a673a9aa129efa002
BLAKE2b-256 48a0e7624363323f0fed2b21b66f3ee19359fb8b80d1d86438785df1bf226135

See more details on using hashes here.

File details

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

File metadata

  • Download URL: msgspec-0.2.0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 147.2 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for msgspec-0.2.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 19eceef01796965ec29a012d969f0fc1bb023ffb39e06ffceff0c6751a054c25
MD5 af045a7471e63dc33d5c78c290abe84d
BLAKE2b-256 1bbd9a99b0d62e468327025e1362803c5df2693a5db07da0081f83c6e2d08d45

See more details on using hashes here.

File details

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

File metadata

  • Download URL: msgspec-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 48.0 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.9.2

File hashes

Hashes for msgspec-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 be1afc8a1ac528bf7f3662b6b7f90acb6f25947e143eb9501c7c67b13736ac4b
MD5 a4e02238c65bffc505998627e3a0f090
BLAKE2b-256 53f2071c9cce71bc931948510b10bbbe558947dc1344c1c18cce41866e95f900

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