Fast and friendly msgpack (de)serialization, with type validation
Project description
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.
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.3.2.tar.gz
(50.2 kB
view hashes)
Built Distributions
Close
Hashes for msgspec-0.3.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f86a687a7b0b449723d9c3c82e9d34f60f086018ff44bfb43da17ff53d88c0d6 |
|
MD5 | 62627565a785ce7f2d624de9617cca9e |
|
BLAKE2b-256 | f9d8a15c208bab53d1344b3c5740473cc008b6b4217cd10e95cd89ace14922e7 |
Close
Hashes for msgspec-0.3.2-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53e0468c1d0ebff5a856d278bf5d71e89ddfeb5f84cbe1302acb43b5078845f9 |
|
MD5 | aadc744a7fc1ad009eb130fcc4d0c5e1 |
|
BLAKE2b-256 | 478dd729638ffa6f4e29f1f2eae3caac34fcb611b42f5affe91c27e8f110a97f |
Close
Hashes for msgspec-0.3.2-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bb037970ee4135714c9130486ef97614e8e4303a1ef2ec8ee6cc7fca8803910 |
|
MD5 | cd75f45d1f6fe5008e397979231e81fa |
|
BLAKE2b-256 | 4ed005bb5d654b93cf11b5b46b5a5d5cf61eec20b5f5c33b0fd59582036b047e |
Close
Hashes for msgspec-0.3.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 787a1000aa17991a514d00605814a3a82499ad81c05d68fac0fb684fdda9580a |
|
MD5 | a6470a52efffac4abf394a044fa1e4c9 |
|
BLAKE2b-256 | f7c88785abcba17d9a25534fa48dedd978ca754f57fd35689c89ba0d874490e7 |
Close
Hashes for msgspec-0.3.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87c3de89d62a2b1e8510aacc985023a28362fadf41d290106e6a4124c06a6515 |
|
MD5 | f1bb89f3c31c54c0975845a25cab94a3 |
|
BLAKE2b-256 | be7ff47e48f737e476536ce6cb7df1a28d6eb2432ef6edfacf587d4bfef99463 |
Close
Hashes for msgspec-0.3.2-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 962b8e46f0f83b34de0c37bbfe5744336e0b541da547dea9a39bea5024c4d0b5 |
|
MD5 | a6d2ddf04bb783acdd0483d4875d452c |
|
BLAKE2b-256 | 401f3df51643bb4a6a31b1a9cf8a3b3ae9e035da2a1fb996c610c0f95524f622 |
Close
Hashes for msgspec-0.3.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 929651155b62a90be68971fd56acd1d742e1de2cdd1c3e67a13707b5ee245d04 |
|
MD5 | 93f8e1ff74048c5a8cc34aed0dabc3f6 |
|
BLAKE2b-256 | 424b496bfdfab22a815ba8de228a0be6dfd48dbb2f2e4d0d9063ec48f822ad06 |
Close
Hashes for msgspec-0.3.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0666bb757127bbcc30b8118da3390ea63aa247be13f2b73f07f7bb7aafc3b8ac |
|
MD5 | 7c3378bca965eed4e17a34e04d67c1ac |
|
BLAKE2b-256 | c44fa1d26fa9b4caed17971d9457aff2de374c202c20ca64e90d7b06a939da4f |