Typed message serialization
Project description
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.
See the documentation for more information.
LICENSE
New BSD. See the License File.
Project details
Release history Release notifications | RSS feed
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 hashes)
Built Distributions
Close
Hashes for msgspec-0.2.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3aead3ef0bc7b439b21ba18078d52a8755140a2fb59ff337ba8143316728ffd7 |
|
MD5 | 41b8bcc170e6f94f579dc31a42721be5 |
|
BLAKE2b-256 | 9b49e4ddbf482b9727fcadf7a55e602fa1b649ab588e416df2aa6279cc95eb30 |
Close
Hashes for msgspec-0.2.0-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4889b1e8f24ac28bd3290ecd24216952d344e702ca35d7a56cefe667c6296eeb |
|
MD5 | 56cea9116bb64442203f8eeb2a881a2e |
|
BLAKE2b-256 | c0b0324adde174a6c5186467f6639a76b46c382eb7e176dbb80fd36354878bc2 |
Close
Hashes for msgspec-0.2.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eebdbae479d2e3a9601738fecbbe0eead2ae5b17b699bf753658c820ea5060a9 |
|
MD5 | b6f1560cb9513a838636baa2e6fbbd35 |
|
BLAKE2b-256 | 0405ce2a6c22e8d40407ad5ea33500addbcce47afe1a11b8dc7a22bd2c06d38f |
Close
Hashes for msgspec-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c84e2e92ada187fce9882585a271f248974bb816dd779fe32c66967f6b3f5cc1 |
|
MD5 | 6daef762185fea6f7523ce5f07f75e54 |
|
BLAKE2b-256 | fb64861739b20777ecf658e11192e67ca68dfe54d027a6c6fbf0bca16aeb082a |
Close
Hashes for msgspec-0.2.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07b685ee1513f3e1fe63540fd670dae6ce4ec084fa4fd6ffeb31b4ddc6c9d8d1 |
|
MD5 | dcbc48168b4f6e5a55b4e1bd95392e1c |
|
BLAKE2b-256 | 9853e35814fd28f4ce9a399101e3cdcec22eaa3b81ba126cd5622b07bfe3ca93 |
Close
Hashes for msgspec-0.2.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37e26a88de26dfd47090f9ef44e9787b488f370f4321e5e6e9ad052a46948b75 |
|
MD5 | 0d7a4c555932902a673a9aa129efa002 |
|
BLAKE2b-256 | 48a0e7624363323f0fed2b21b66f3ee19359fb8b80d1d86438785df1bf226135 |
Close
Hashes for msgspec-0.2.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19eceef01796965ec29a012d969f0fc1bb023ffb39e06ffceff0c6751a054c25 |
|
MD5 | af045a7471e63dc33d5c78c290abe84d |
|
BLAKE2b-256 | 1bbd9a99b0d62e468327025e1362803c5df2693a5db07da0081f83c6e2d08d45 |
Close
Hashes for msgspec-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be1afc8a1ac528bf7f3662b6b7f90acb6f25947e143eb9501c7c67b13736ac4b |
|
MD5 | a4e02238c65bffc505998627e3a0f090 |
|
BLAKE2b-256 | 53f2071c9cce71bc931948510b10bbbe558947dc1344c1c18cce41866e95f900 |