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.0.tar.gz
(48.9 kB
view hashes)
Built Distributions
Close
Hashes for msgspec-0.3.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afd8d87489ff2f0ae369faae76a94d47914c2985b802b05ef03ae4b7701d9b70 |
|
MD5 | 5aa05f2e134a0bf6c7bcbdb6b8da546b |
|
BLAKE2b-256 | 51ecb4c88d613069aec4b765b64201aabe1ee31d2e59636bcbacb83ef9d790c3 |
Close
Hashes for msgspec-0.3.0-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 487f2826e20f9fb799ab4d655db9dbc47dad0bb95c6fc0ab06a84e299c6f8de3 |
|
MD5 | 09a1a17cd340e643a10011f43648e6ef |
|
BLAKE2b-256 | 644faf562fd31e87fcf9b85e4369524364c4fb58b7ebbd04707b1b8da00d92b2 |
Close
Hashes for msgspec-0.3.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 699e9770e6da2929cc8e9ed7b250a8555777ca64de76df2e2c17824c2ecafe83 |
|
MD5 | 234d63b384bea07979f21c07bded4f50 |
|
BLAKE2b-256 | 4d38b8f9d388a71e7e69813e6a2e489d50de1a3c2127c4a9ee91cbd1532e1c59 |
Close
Hashes for msgspec-0.3.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa7c5dcaca5e9bc054c2e0d3e01d8bb7d5c1f9c16caf05dff223ab996d3fc2ec |
|
MD5 | ceb94bacd4950dac1cfea72c72a1f6e1 |
|
BLAKE2b-256 | 1ea3225469c8e6d3146f25f589f92c2da76d752be9badd0afe8b91368d9d1947 |
Close
Hashes for msgspec-0.3.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6cfff8ab6cbd20f26f08bd9d89ed3ec38834cfdbc1da72bc0cc41990083132a |
|
MD5 | ec568a71ca5509142e4dbbe0d12b9dad |
|
BLAKE2b-256 | 0a3e09e0782783fc71531d4e3d2e7d8c9bc57c578fd29e7dc93ab9b008639141 |
Close
Hashes for msgspec-0.3.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3f57349e0dbd22662d3a75b8f6c911d3c3e05bd1c701c9e57862474804f9e4a |
|
MD5 | 66a9544ba94ed7011e3ee8a850a6713f |
|
BLAKE2b-256 | b14e74e6274720be4402567905f9e4d77e4d28add5a00e7dc84efbab7b5153b2 |
Close
Hashes for msgspec-0.3.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab529c6f22c7874768a2ba187b9d8065b717c7f9068ffcdc4e954f6cdc10f292 |
|
MD5 | 51084bd4a1c79dd002766f2713cd0da0 |
|
BLAKE2b-256 | a601085d3b8db1c29f1aaa15e410e01d4f476703340b2c48bf2cc43d055c68fa |
Close
Hashes for msgspec-0.3.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 279c4a1c0a26f904a9ff8a2e90b32c2cf2daab27b4b057ce990ec36013e9abef |
|
MD5 | f4f9a8dda36afb5fbc2c5b0ad863ddcf |
|
BLAKE2b-256 | 5737f964284195d0784b74fe3c7cbea90f5c51f0aa82511d1529ce34553d0abe |