msgspec
توضیحات
A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | msgspec-0.9.1 |
| نام | msgspec |
| نسخه کتابخانه | 0.9.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | ['Jim Crist-Harif <jcristharif@gmail.com>, Ofek Lev <oss@ofek.dev>, Nikita Sobolev <mail@sobolevn.me>'] |
| نویسنده | - |
| ایمیل نویسنده | - |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/msgspec/ |
| مجوز | - |
<p align="center">
<a href="https://msgspec.dev">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/msgspec/msgspec/main/docs/_static/msgspec-logo-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/msgspec/msgspec/main/docs/_static/msgspec-logo-light.svg">
<img src="https://raw.githubusercontent.com/msgspec/msgspec/main/docs/_static/msgspec-logo-light.svg" width="35%" alt="msgspec">
</picture>
</a>
</p>
<div align="center">
[](https://github.com/msgspec/msgspec/actions/workflows/ci.yml)
[](https://msgspec.dev)
[](https://github.com/msgspec/msgspec/blob/main/LICENSE)
[](https://pypi.org/project/msgspec/)
[](https://anaconda.org/conda-forge/msgspec)
[](https://app.codecov.io/gh/msgspec/msgspec)
</div>
`msgspec` is a *fast* serialization and validation library, with builtin
support for [JSON](https://json.org), [MessagePack](https://msgpack.org),
[YAML](https://yaml.org), and [TOML](https://toml.io/en/). It features:
- 🚀 **High performance encoders/decoders** for common protocols. The JSON and
MessagePack implementations regularly
[benchmark](https://msgspec.dev/benchmarks) as the fastest
options for Python.
- 🎉 **Support for a wide variety of Python types**. Additional types may be
supported through
[extensions](https://msgspec.dev/extending).
- 🔍 **Zero-cost schema validation** using familiar Python type annotations. In
[benchmarks](https://msgspec.dev/benchmarks) `msgspec`
decodes *and* validates JSON faster than
[orjson](https://github.com/ijl/orjson) can decode it alone.
- ✨ **A speedy Struct type** for representing structured data. If you already
use [dataclasses](https://docs.python.org/3/library/dataclasses.html) or
[attrs](https://www.attrs.org/en/stable/),
[structs](https://msgspec.dev/structs) should feel familiar.
However, they're
[5-60x faster](https://msgspec.dev/benchmarks#structs)
for common operations.
All of this is included in a
[lightweight library](https://msgspec.dev/benchmarks#library-size)
with no required dependencies.
---
`msgspec` may be used for serialization alone, as a faster JSON or
MessagePack library. For the greatest benefit though, we recommend using
`msgspec` to handle the full serialization & validation workflow:
**Define** your message schemas using standard Python type annotations.
```python
>>> import msgspec
>>> class User(msgspec.Struct):
... """A new type describing a User"""
... name: str
... groups: set[str] = set()
... email: str | None = None
```
**Encode** messages as JSON, or one of the many other supported protocols.
```python
>>> alice = User("alice", groups={"admin", "engineering"})
>>> alice
User(name='alice', groups={"admin", "engineering"}, email=None)
>>> msg = msgspec.json.encode(alice)
>>> msg
b'{"name":"alice","groups":["admin","engineering"],"email":null}'
```
**Decode** messages back into Python objects, with optional schema validation.
```python
>>> msgspec.json.decode(msg, type=User)
User(name='alice', groups={"admin", "engineering"}, email=None)
>>> msgspec.json.decode(b'{"name":"bob","groups":[123]}', type=User)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
msgspec.ValidationError: Expected `str`, got `int` - at `$.groups[0]`
```
`msgspec` is designed to be as performant as possible, while retaining some of
the nicities of validation libraries like
[pydantic](https://pydantic.dev/docs/validation/latest/get-started/). For supported types,
encoding/decoding a message with `msgspec` can be
[~10-80x faster than alternative libraries](https://msgspec.dev/benchmarks).
<p align="center">
<a href="https://msgspec.dev/benchmarks">
<img src="https://raw.githubusercontent.com/msgspec/msgspec/main/docs/_static/bench-validation.svg">
</a>
</p>
See [the documentation](https://msgspec.dev) for more information.
## LICENSE
New BSD. See the
[License File](https://github.com/msgspec/msgspec/blob/main/LICENSE).
نیازمندی
| مقدار | نام |
|---|---|
| ython_versio | tomli; |
| xtr | tomli_w; |
| xtr | pyyaml; |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.10 | Python |
نحوه نصب
نصب پکیج whl msgspec-0.9.1:
pip install msgspec.whl
نصب پکیج tar.gz msgspec-0.9.1:
pip install msgspec.tar.gz