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.1.tar.gz
(49.9 kB
view hashes)
Built Distributions
Close
Hashes for msgspec-0.3.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07bc3e4783fe3ac6bd6bf3bee8d962f121b5ee572588ad015a7738f57be1afa9 |
|
MD5 | d51edd9feb4f43746cade243b404f925 |
|
BLAKE2b-256 | 6bed56f136f04868283cb57b02a4e2a2b6b0d0e7c18e59afecad4a8c40ec0455 |
Close
Hashes for msgspec-0.3.1-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 427cf2fbce30492fc8e63d265dfc79092d1fef5a49c8b6215d62bec769c784b1 |
|
MD5 | 824151cba978128965a7f66936e9e22a |
|
BLAKE2b-256 | 94c1e4b2d696024edf10bd10c9c77bfad42448cef08d174595cf9f1baf91ec01 |
Close
Hashes for msgspec-0.3.1-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64a162db72c566c4dd841f8e7fa12b67a1f1e05795cb05233db538829edb5e6d |
|
MD5 | 304c3154b7fd1ed9f6f9ce810d503bd9 |
|
BLAKE2b-256 | 838c27b5f44852b7d1debea6e9d796dd70d3d97c4320fe3f1ecd56f80234a35c |
Close
Hashes for msgspec-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 240b409a37847e735d0a409217e2ca1a2b3f1703fdee923610b9216a41ba0d21 |
|
MD5 | 1c5e6603a2afb492220ced88f4f3f522 |
|
BLAKE2b-256 | 9c7fe50fe8c28ce705395e9ee2ad8f94a2dc58d6f5dca2b3261ad2f4a8bc3880 |
Close
Hashes for msgspec-0.3.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b9c64945381ceb69fe9f32cb4a0a55cb693bccfca2b5597cf9bab50310ecdfd |
|
MD5 | 9916798093f58d44129d62feb48e1e1f |
|
BLAKE2b-256 | 63685c08fc398582cb164b89be50ec4d5c0d23322a9fe003fbe9fcf50b96a3ef |
Close
Hashes for msgspec-0.3.1-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffbe371bd96c57664d36b5a7ba04de41779e23d993fbe2e7279bb07e946864bd |
|
MD5 | fb67c2b8bcbcc2455be16d61015c6cc8 |
|
BLAKE2b-256 | 26d228f326508a4a0db6fb66c52d4516dc1268f5e22d65c7fb093feaa1c8c473 |
Close
Hashes for msgspec-0.3.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3413bc40c1f096a668dd4c73e61dede9946812e80d140163d9da04cae520dbce |
|
MD5 | 80050667ac39df21bb85e98ac04e94b8 |
|
BLAKE2b-256 | 093a3188057367f60778ab21e97d256eb9263121bfd91498d624f148f997608c |
Close
Hashes for msgspec-0.3.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c64a75c1a2357a13acb20ed088f63518f43a15cbcf4c4c612328e88c2f223f4a |
|
MD5 | 548fb920e2329331ad3a11edf9b9a930 |
|
BLAKE2b-256 | 755f3d683c8ca37c0a83dbaa11dceb36202911b80a56c6ecef1ce73cc8cdd521 |