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.1.0.tar.gz
(40.4 kB
view hashes)
Built Distributions
Close
Hashes for msgspec-0.1.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad9223039b7179d1a026aa8a2a79babc844383566e04afe26dc7e681b806c9f0 |
|
MD5 | bbe9ec00f4f87fa643575dc0bbaa07d4 |
|
BLAKE2b-256 | 9297d1683e89c2391d6454276dd5abc1300e8aa3936ad59d7532fcfa2f3aa26b |
Close
Hashes for msgspec-0.1.0-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46e93bab2acc07982564004efe15485983b594e3d75c803c9fb6cf2d80995733 |
|
MD5 | 1e524530c3aceed4abbca2fea9d051d0 |
|
BLAKE2b-256 | bc51ca1ff2c2f4be427650d48cfa4b8007b06ecfe045ede141bbc9dd06565f4c |
Close
Hashes for msgspec-0.1.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 367972443493e13029744d215a6ef93fcb776c523f24ae1b43261b804cf5ec3b |
|
MD5 | 366ff7fc8d173bd9ae45e9e32d5271cb |
|
BLAKE2b-256 | 45d6f1ffdcd3fc3b91bd51ad16cbbded7201453bd88edb0e587b622a71c92732 |
Close
Hashes for msgspec-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f554e888fd278eaa4c9384183314bf1aaea357f3bc0d948b31be9e96666bc57b |
|
MD5 | b0022619b594ceb11effa39cd00e98f6 |
|
BLAKE2b-256 | 102e47c0361c22d82ee599e8c7c8cc6acc6d08ce9d1467fd8af823307d91f56a |
Close
Hashes for msgspec-0.1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f06790a427562b2c417157b528249a74fd8866d06cf1e06d8b069b4fcd2b8bfc |
|
MD5 | 27d495b404f9f08ba89d636268569235 |
|
BLAKE2b-256 | 0c80f1d9d8c183b4f78f4b3732ad1795a7da17fc829c1ac60c52992bbf68619d |
Close
Hashes for msgspec-0.1.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21e0059d1e8d9cc4bd17b66e2b5bbf3629167b5a65646863410ae537e4db6f2c |
|
MD5 | 805d7029efe6e10d8c594193f080ce3f |
|
BLAKE2b-256 | fc3aa138ac8a8f45ac222a505dd0d2bd85c0e1a50f6a29129b6f3ef9ef9fcb1d |
Close
Hashes for msgspec-0.1.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bf2d5a540a8f28038ae60b212dde333405a9de0271f8ab01a37b9c5072f7169 |
|
MD5 | 11e165089cc6077d6d5e2fe257715e1b |
|
BLAKE2b-256 | 6a4c2466536798e980d23ae14ba41860063c1348146996606e361196a3c1498d |
Close
Hashes for msgspec-0.1.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c54a76252926072e36e88446dffdb6de39a59efd88ceb3fda12aa21f24fe33ea |
|
MD5 | f9fde6e8e484d84e4ec4604738d39af5 |
|
BLAKE2b-256 | 54652cd33cfef1e44ddda35e94de3829542fafdf1059d389aa7e3dee2ed74a2f |