Skip to content

Commit

Permalink
Move readme to markdown
Browse files Browse the repository at this point in the history
The recent changes to freshen up the readme don't render properly on
PyPI, because PyPI doesn't support

- The `raw` restructured text directive (but they do support raw html in
  markdown docs).
- The html `<picture>` tag in general

To work around this we move the readme to markdown, and drop the
light/dark rendering of the logo in the GitHub readme. We could support
this by transforming the readme before uploading to PyPI, but that seems
like too much work for too little benefit.
  • Loading branch information
jcrist committed Feb 9, 2023
1 parent c41bd35 commit 04bfb52
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 138 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ include msgspec/*.pyi
include msgspec/py.typed
include setup.py
include versioneer.py
include README.rst
include README.md
include LICENSE
include MANIFEST.in
121 changes: 121 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<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 ~2x 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
[10-100x 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
[~2-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-1.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).
135 changes: 0 additions & 135 deletions README.rst

This file was deleted.

5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@
package_data={"msgspec": ["py.typed", "*.pyi"]},
ext_modules=ext_modules,
long_description=(
open("README.rst", encoding="utf-8").read()
if os.path.exists("README.rst")
open("README.md", encoding="utf-8").read()
if os.path.exists("README.md")
else ""
),
long_description_content_type="text/markdown",
python_requires=">=3.8",
zip_safe=False,
)

0 comments on commit 04bfb52

Please sign in to comment.