<p align="center">
<a href="https://jcristharif.com/msgspec/">
<img src="https://raw.githubusercontent.com/jcrist/msgspec/main/docs/source/_static/msgspec-logo-light.svg" width="35%" alt="msgspec" />
</a>
</p>
<p align="center">
<a href="https://github.com/jcrist/msgspec/actions/workflows/ci.yml">
<img src="https://github.com/jcrist/msgspec/actions/workflows/ci.yml/badge.svg">
</a>
<a href="https://jcristharif.com/msgspec/">
<img src="https://img.shields.io/badge/docs-latest-blue.svg">
</a>
<a href="https://github.com/jcrist/msgspec/blob/main/LICENSE">
<img src="https://img.shields.io/github/license/jcrist/msgspec.svg">
</a>
<a href="https://pypi.org/project/msgspec/">
<img src="https://img.shields.io/pypi/v/msgspec.svg">
</a>
<a href="https://anaconda.org/conda-forge/msgspec">
<img src="https://img.shields.io/conda/vn/conda-forge/msgspec.svg">
</a>
<a href="https://codecov.io/gh/jcrist/msgspec">
<img src="https://codecov.io/gh/jcrist/msgspec/branch/main/graph/badge.svg">
</a>
</p>
`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). It features:
- 🚀 **High performance encoders/decoders** for common protocols. The JSON and
MessagePack implementations regularly
[benchmark](https://jcristharif.com/msgspec/benchmarks.html) as the fastest
options for Python.
- 🎉 **Support for a wide variety of Python types**. Additional types may be
supported through
[extensions](https://jcristharif.com/msgspec/extending.html).
- 🔍 **Zero-cost schema validation** using familiar Python type annotations. In
[benchmarks](https://jcristharif.com/msgspec/benchmarks.html) `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),
[structs](https://jcristharif.com/msgspec/structs.html) should feel familiar.
However, they're
[5-60x faster](https://jcristharif.com/msgspec/benchmarks.html#benchmark-structs>)
for common operations.
All of this is included in a
[lightweight library](https://jcristharif.com/msgspec/benchmarks.html#benchmark-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-docs.helpmanual.io/). For supported types,
encoding/decoding a message with `msgspec` can be
[~10-80x faster than alternative libraries](https://jcristharif.com/msgspec/benchmarks.html).
<p align="center">
<a href="https://jcristharif.com/msgspec/benchmarks.html">
<img src="https://raw.githubusercontent.com/jcrist/msgspec/main/docs/source/_static/bench-validation.svg">
</a>
</p>
See [the documentation](https://jcristharif.com/msgspec/) for more information.
## LICENSE
New BSD. See the
[License File](https://github.com/jcrist/msgspec/blob/main/LICENSE).
Raw data
{
"_id": null,
"home_page": null,
"name": "msgspec-python313-pre",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "Jim Crist-Harif <jcristharif@gmail.com>",
"keywords": "JSON msgpack MessagePack TOML YAML serialization validation schema",
"author": null,
"author_email": "Jim Crist-Harif <jcristharif@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/dc/a2/143399a9a3b5009543db13b7e33a3155a9d65bcbe2f1259d2bce3dfda2ac/msgspec_python313_pre-0.19.3.tar.gz",
"platform": null,
"description": "<p align=\"center\">\n <a href=\"https://jcristharif.com/msgspec/\">\n <img src=\"https://raw.githubusercontent.com/jcrist/msgspec/main/docs/source/_static/msgspec-logo-light.svg\" width=\"35%\" alt=\"msgspec\" />\n </a>\n</p>\n\n<p align=\"center\">\n <a href=\"https://github.com/jcrist/msgspec/actions/workflows/ci.yml\">\n <img src=\"https://github.com/jcrist/msgspec/actions/workflows/ci.yml/badge.svg\">\n </a>\n <a href=\"https://jcristharif.com/msgspec/\">\n <img src=\"https://img.shields.io/badge/docs-latest-blue.svg\">\n </a>\n <a href=\"https://github.com/jcrist/msgspec/blob/main/LICENSE\">\n <img src=\"https://img.shields.io/github/license/jcrist/msgspec.svg\">\n </a>\n <a href=\"https://pypi.org/project/msgspec/\">\n <img src=\"https://img.shields.io/pypi/v/msgspec.svg\">\n </a>\n <a href=\"https://anaconda.org/conda-forge/msgspec\">\n <img src=\"https://img.shields.io/conda/vn/conda-forge/msgspec.svg\">\n </a>\n <a href=\"https://codecov.io/gh/jcrist/msgspec\">\n <img src=\"https://codecov.io/gh/jcrist/msgspec/branch/main/graph/badge.svg\">\n </a>\n</p>\n\n\n`msgspec` is a *fast* serialization and validation library, with builtin\nsupport for [JSON](https://json.org), [MessagePack](https://msgpack.org),\n[YAML](https://yaml.org), and [TOML](https://toml.io). It features:\n\n- \ud83d\ude80 **High performance encoders/decoders** for common protocols. The JSON and\n MessagePack implementations regularly\n [benchmark](https://jcristharif.com/msgspec/benchmarks.html) as the fastest\n options for Python.\n\n- \ud83c\udf89 **Support for a wide variety of Python types**. Additional types may be\n supported through\n [extensions](https://jcristharif.com/msgspec/extending.html).\n\n- \ud83d\udd0d **Zero-cost schema validation** using familiar Python type annotations. In\n [benchmarks](https://jcristharif.com/msgspec/benchmarks.html) `msgspec`\n decodes *and* validates JSON faster than\n [orjson](https://github.com/ijl/orjson) can decode it alone.\n\n- \u2728 **A speedy Struct type** for representing structured data. If you already\n use [dataclasses](https://docs.python.org/3/library/dataclasses.html) or\n [attrs](https://www.attrs.org),\n [structs](https://jcristharif.com/msgspec/structs.html) should feel familiar.\n However, they're\n [5-60x faster](https://jcristharif.com/msgspec/benchmarks.html#benchmark-structs>)\n for common operations.\n\nAll of this is included in a\n[lightweight library](https://jcristharif.com/msgspec/benchmarks.html#benchmark-library-size)\nwith no required dependencies.\n\n---\n\n`msgspec` may be used for serialization alone, as a faster JSON or\nMessagePack library. For the greatest benefit though, we recommend using\n`msgspec` to handle the full serialization & validation workflow:\n\n**Define** your message schemas using standard Python type annotations.\n\n```python\n>>> import msgspec\n\n>>> class User(msgspec.Struct):\n... \"\"\"A new type describing a User\"\"\"\n... name: str\n... groups: set[str] = set()\n... email: str | None = None\n```\n\n**Encode** messages as JSON, or one of the many other supported protocols.\n\n```python\n>>> alice = User(\"alice\", groups={\"admin\", \"engineering\"})\n\n>>> alice\nUser(name='alice', groups={\"admin\", \"engineering\"}, email=None)\n\n>>> msg = msgspec.json.encode(alice)\n\n>>> msg\nb'{\"name\":\"alice\",\"groups\":[\"admin\",\"engineering\"],\"email\":null}'\n```\n\n**Decode** messages back into Python objects, with optional schema validation.\n\n```python\n>>> msgspec.json.decode(msg, type=User)\nUser(name='alice', groups={\"admin\", \"engineering\"}, email=None)\n\n>>> msgspec.json.decode(b'{\"name\":\"bob\",\"groups\":[123]}', type=User)\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nmsgspec.ValidationError: Expected `str`, got `int` - at `$.groups[0]`\n```\n\n`msgspec` is designed to be as performant as possible, while retaining some of\nthe nicities of validation libraries like\n[pydantic](https://pydantic-docs.helpmanual.io/). For supported types,\nencoding/decoding a message with `msgspec` can be\n[~10-80x faster than alternative libraries](https://jcristharif.com/msgspec/benchmarks.html).\n\n<p align=\"center\">\n <a href=\"https://jcristharif.com/msgspec/benchmarks.html\">\n <img src=\"https://raw.githubusercontent.com/jcrist/msgspec/main/docs/source/_static/bench-validation.svg\">\n </a>\n</p>\n\nSee [the documentation](https://jcristharif.com/msgspec/) for more information.\n\n\n## LICENSE\n\nNew BSD. See the\n[License File](https://github.com/jcrist/msgspec/blob/main/LICENSE).\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML.",
"version": "0.19.3",
"project_urls": {
"Documentation": "https://jcristharif.com/msgspec/",
"Homepage": "https://jcristharif.com/msgspec/",
"Issue Tracker": "https://github.com/jcrist/msgspec/issues",
"Source": "https://github.com/jcrist/msgspec/"
},
"split_keywords": [
"json",
"msgpack",
"messagepack",
"toml",
"yaml",
"serialization",
"validation",
"schema"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7427a062c7e34f3d8f7dbd981019b3e7511a62d2ca2ca8823c226d1ea9d5787c",
"md5": "75415399e8b4909948de5b47fe2b8e03",
"sha256": "42318174762a931fe550371d8e618cbe05b66a24190ea3dfec456b473678ba11"
},
"downloads": -1,
"filename": "msgspec_python313_pre-0.19.3-cp313-cp313-macosx_15_0_x86_64.whl",
"has_sig": false,
"md5_digest": "75415399e8b4909948de5b47fe2b8e03",
"packagetype": "bdist_wheel",
"python_version": "cp313",
"requires_python": ">=3.9",
"size": 391937,
"upload_time": "2024-11-08T14:51:15",
"upload_time_iso_8601": "2024-11-08T14:51:15.255568Z",
"url": "https://files.pythonhosted.org/packages/74/27/a062c7e34f3d8f7dbd981019b3e7511a62d2ca2ca8823c226d1ea9d5787c/msgspec_python313_pre-0.19.3-cp313-cp313-macosx_15_0_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "dca2143399a9a3b5009543db13b7e33a3155a9d65bcbe2f1259d2bce3dfda2ac",
"md5": "5229841f7e3bd6f8aaf1a793af1023b1",
"sha256": "14394993ce7d149652067ebc77d2889727974af06975fce5d572658ac9f5136e"
},
"downloads": -1,
"filename": "msgspec_python313_pre-0.19.3.tar.gz",
"has_sig": false,
"md5_digest": "5229841f7e3bd6f8aaf1a793af1023b1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 316769,
"upload_time": "2024-11-08T14:51:17",
"upload_time_iso_8601": "2024-11-08T14:51:17.434215Z",
"url": "https://files.pythonhosted.org/packages/dc/a2/143399a9a3b5009543db13b7e33a3155a9d65bcbe2f1259d2bce3dfda2ac/msgspec_python313_pre-0.19.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-08 14:51:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jcrist",
"github_project": "msgspec",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "msgspec-python313-pre"
}