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

Uploaded Source

Built Distributions

msgspec-0.3.2-cp39-cp39-win_amd64.whl (71.7 kB view details)

Uploaded CPython 3.9 Windows x86-64

msgspec-0.3.2-cp39-cp39-manylinux2010_x86_64.whl (192.8 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

msgspec-0.3.2-cp39-cp39-manylinux1_x86_64.whl (192.8 kB view details)

Uploaded CPython 3.9

msgspec-0.3.2-cp39-cp39-macosx_10_9_x86_64.whl (66.1 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

msgspec-0.3.2-cp38-cp38-win_amd64.whl (71.5 kB view details)

Uploaded CPython 3.8 Windows x86-64

msgspec-0.3.2-cp38-cp38-manylinux2010_x86_64.whl (193.1 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

msgspec-0.3.2-cp38-cp38-manylinux1_x86_64.whl (193.1 kB view details)

Uploaded CPython 3.8

msgspec-0.3.2-cp38-cp38-macosx_10_9_x86_64.whl (66.1 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for msgspec-0.3.2.tar.gz
Algorithm Hash digest
SHA256 82f9219f2420f427599bee9a0776fb582ebfb14f686ac19cc992b36d9347116f
MD5 e7cb274cde6beb5f162db18d99202f01
BLAKE2b-256 1e0014bfc0c56f0ad816ab3dda27ae0747e4b95a24926352e2286f64c67007eb

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for msgspec-0.3.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f86a687a7b0b449723d9c3c82e9d34f60f086018ff44bfb43da17ff53d88c0d6
MD5 62627565a785ce7f2d624de9617cca9e
BLAKE2b-256 f9d8a15c208bab53d1344b3c5740473cc008b6b4217cd10e95cd89ace14922e7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for msgspec-0.3.2-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 53e0468c1d0ebff5a856d278bf5d71e89ddfeb5f84cbe1302acb43b5078845f9
MD5 aadc744a7fc1ad009eb130fcc4d0c5e1
BLAKE2b-256 478dd729638ffa6f4e29f1f2eae3caac34fcb611b42f5affe91c27e8f110a97f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for msgspec-0.3.2-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0bb037970ee4135714c9130486ef97614e8e4303a1ef2ec8ee6cc7fca8803910
MD5 cd75f45d1f6fe5008e397979231e81fa
BLAKE2b-256 4ed005bb5d654b93cf11b5b46b5a5d5cf61eec20b5f5c33b0fd59582036b047e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for msgspec-0.3.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 787a1000aa17991a514d00605814a3a82499ad81c05d68fac0fb684fdda9580a
MD5 a6470a52efffac4abf394a044fa1e4c9
BLAKE2b-256 f7c88785abcba17d9a25534fa48dedd978ca754f57fd35689c89ba0d874490e7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for msgspec-0.3.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 87c3de89d62a2b1e8510aacc985023a28362fadf41d290106e6a4124c06a6515
MD5 f1bb89f3c31c54c0975845a25cab94a3
BLAKE2b-256 be7ff47e48f737e476536ce6cb7df1a28d6eb2432ef6edfacf587d4bfef99463

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for msgspec-0.3.2-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 962b8e46f0f83b34de0c37bbfe5744336e0b541da547dea9a39bea5024c4d0b5
MD5 a6d2ddf04bb783acdd0483d4875d452c
BLAKE2b-256 401f3df51643bb4a6a31b1a9cf8a3b3ae9e035da2a1fb996c610c0f95524f622

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for msgspec-0.3.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 929651155b62a90be68971fd56acd1d742e1de2cdd1c3e67a13707b5ee245d04
MD5 93f8e1ff74048c5a8cc34aed0dabc3f6
BLAKE2b-256 424b496bfdfab22a815ba8de228a0be6dfd48dbb2f2e4d0d9063ec48f822ad06

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for msgspec-0.3.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0666bb757127bbcc30b8118da3390ea63aa247be13f2b73f07f7bb7aafc3b8ac
MD5 7c3378bca965eed4e17a34e04d67c1ac
BLAKE2b-256 c44fa1d26fa9b4caed17971d9457aff2de374c202c20ca64e90d7b06a939da4f

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