Skip to content

Commit 1159ee7

Browse files
committed
Merge branch 'release/v0.20'
2 parents f9bd49f + fef1e0d commit 1159ee7

File tree

22 files changed

+501
-138
lines changed

22 files changed

+501
-138
lines changed

.github/CONTRIBUTING.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# How to Contribute
22

3-
Thank you for taking the time to contribute to `msgspec`!
3+
Thank you for taking the time to contribute to `msgspec-x`!
44

55
Here we document some contribution guidelines to help you ensure that your
66
contribution is at its best.
@@ -17,17 +17,17 @@ Once you have those installed, you're ready to:
1717

1818
- Clone the repository
1919
- Install all development dependencies
20-
- Build a development version of `msgspec`
20+
- Build a development version of `msgspec-x`
2121
- Install the `pre-commit` hooks
2222

2323
```bash
2424
# Clone the repository
25-
git clone https://github.com/jcrist/msgspec.git
25+
git clone https://github.com/nightsailer/msgspec-x.git
2626

2727
# cd into the repo root directory
28-
cd msgspec/
28+
cd msgspec-x/
2929

30-
# Build and install msgspec & all dev dependencies
30+
# Build and install msgspec-x & all dev dependencies
3131
pip install -e ".[dev]"
3232

3333
# Install the pre-commit hooks
@@ -36,9 +36,9 @@ pre-commit install
3636

3737
## Editing and Rebuilding
3838

39-
You now have a "development" build of `msgspec` installed. This means that you
39+
You now have a "development" build of `msgspec-x` installed. This means that you
4040
can make changes to the `.py` files and test them without requiring a rebuild
41-
of msgspec's C extension. Edit away!
41+
of msgspec-x's C extension. Edit away!
4242

4343
If you do make changes to a `.c` file, you'll need to recompile. You can do
4444
this by running
@@ -47,7 +47,7 @@ this by running
4747
pip install -e .
4848
```
4949

50-
By default `msgspec` is built in release mode, with optimizations enabled. To
50+
By default `msgspec-x` is built in release mode, with optimizations enabled. To
5151
build a debug build instead (for use with e.g. `gdb` or `lldb`) define the
5252
`MSGSPEC_DEBUG` environment variable before building.
5353

@@ -112,6 +112,6 @@ and fix any issues that come up.
112112

113113
## Code of Conduct
114114

115-
``msgspec`` has a code of conduct that must be followed by all contributors to
115+
``msgspec-x`` has a code of conduct that must be followed by all contributors to
116116
the project. You may read the code of conduct
117-
[here](https://github.com/jcrist/msgspec/blob/main/CODE_OF_CONDUCT.md).
117+
[here](https://github.com/nightsailer/msgspec-x/blob/main/CODE_OF_CONDUCT.md).

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 🪲 Bug Report
2-
description: Report a bug or unexpected behavior in msgspec
2+
description: Report a bug or unexpected behavior in msgspec-x
33
body:
44
- type: markdown
55
attributes:

.github/ISSUE_TEMPLATE/feature.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 🙌 Feature Request
2-
description: Suggest a new feature or change to msgspec
2+
description: Suggest a new feature or change to msgspec-x
33
body:
44
- type: markdown
55
attributes:

.github/SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Security Policy
22

3-
If you believe you have found a security-related bug with `msgspec`, **do not
4-
open a public GitHub issue**. Instead, please email jcristharif@gmail.com.
3+
If you believe you have found a security-related bug with `msgspec-x`, **do not
4+
open a public GitHub issue**. Instead, please email nightsailer@gmail.com.
55

66
Please include as much detail as you would for a normal issue in your report.
77
In particular, including a minimal reproducible example will help the

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ include msgspec/*.h
33
include msgspec/*.py
44
include msgspec/*.pyi
55
include msgspec/py.typed
6+
include msgspec_x/*.py
7+
include msgspec_x/*.pyi
8+
include msgspec_x/py.typed
69
include setup.py
710
include versioneer.py
811
include README.md

README.md

Lines changed: 116 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,167 @@
1+
# Msgspec-x
2+
3+
14
<p align="center">
2-
<a href="https://jcristharif.com/msgspec/">
5+
<a href="https://nightsailer.github.io/msgspec-x/">
36
<img src="https://raw.githubusercontent.com/jcrist/msgspec/main/docs/source/_static/msgspec-logo-light.svg" width="35%" alt="msgspec" />
47
</a>
58
</p>
69

710
<p align="center">
8-
<a href="https://github.com/jcrist/msgspec/actions/workflows/ci.yml">
9-
<img src="https://github.com/jcrist/msgspec/actions/workflows/ci.yml/badge.svg">
11+
<a href="https://github.com/nightsailer/msgspec-x/actions/workflows/ci.yml">
12+
<img src="https://github.com/nightsailer/msgspec-x/actions/workflows/ci.yml/badge.svg">
1013
</a>
11-
<a href="https://jcristharif.com/msgspec/">
14+
<a href="https://nightsailer.github.io/msgspec-x/">
1215
<img src="https://img.shields.io/badge/docs-latest-blue.svg">
1316
</a>
14-
<a href="https://github.com/jcrist/msgspec/blob/main/LICENSE">
15-
<img src="https://img.shields.io/github/license/jcrist/msgspec.svg">
17+
<a href="https://github.com/nightsailer/msgspec-x/blob/main/LICENSE">
18+
<img src="https://img.shields.io/github/license/nightsailer/msgspec-x.svg">
1619
</a>
17-
<a href="https://pypi.org/project/msgspec/">
18-
<img src="https://img.shields.io/pypi/v/msgspec.svg">
20+
<a href="https://pypi.org/project/msgspec-x/">
21+
<img src="https://img.shields.io/pypi/v/msgspec-x.svg">
1922
</a>
20-
<a href="https://anaconda.org/conda-forge/msgspec">
21-
<img src="https://img.shields.io/conda/vn/conda-forge/msgspec.svg">
23+
<a href="https://anaconda.org/conda-forge/msgspec-x">
24+
<img src="https://img.shields.io/conda/vn/conda-forge/msgspec-x.svg">
2225
</a>
23-
<a href="https://codecov.io/gh/jcrist/msgspec">
24-
<img src="https://codecov.io/gh/jcrist/msgspec/branch/main/graph/badge.svg">
26+
<a href="https://codecov.io/gh/nightsailer/msgspec-x">
27+
<img src="https://codecov.io/gh/nightsailer/msgspec-x/branch/main/graph/badge.svg">
2528
</a>
2629
</p>
2730

31+
## Overview
2832

29-
`msgspec` is a *fast* serialization and validation library, with builtin
30-
support for [JSON](https://json.org), [MessagePack](https://msgpack.org),
31-
[YAML](https://yaml.org), and [TOML](https://toml.io). It features:
33+
`msgspec-x` is a community-driven fork of the [original msgspec library](https://jcristharif.com/msgspec/) by Jim Crist-Harif. This project was created to address the challenge of slow upstream maintenance and to provide a platform for community contributions that couldn't be timely integrated into the original project.
3234

33-
- 🚀 **High performance encoders/decoders** for common protocols. The JSON and
34-
MessagePack implementations regularly
35-
[benchmark](https://jcristharif.com/msgspec/benchmarks.html) as the fastest
36-
options for Python.
35+
### Why msgspec-x?
3736

38-
- 🎉 **Support for a wide variety of Python types**. Additional types may be
39-
supported through
40-
[extensions](https://jcristharif.com/msgspec/extending.html).
37+
The original msgspec library is an excellent project, but the maintainer has limited time to review and merge community pull requests. This has resulted in valuable contributions and bug fixes being stuck in the review process. `msgspec-x` was created to:
4138

42-
- 🔍 **Zero-cost schema validation** using familiar Python type annotations. In
43-
[benchmarks](https://jcristharif.com/msgspec/benchmarks.html) `msgspec`
44-
decodes *and* validates JSON faster than
45-
[orjson](https://github.com/ijl/orjson) can decode it alone.
39+
- **Accelerate community contributions**: Provide a faster path for community PRs and enhancements
40+
- **Enable rapid bug fixes**: Address issues without waiting for upstream review cycles
41+
- **Extend functionality**: Add new features that complement the original design
42+
- **Maintain compatibility**: Keep full backward compatibility with the original msgspec API
4643

47-
-**A speedy Struct type** for representing structured data. If you already
48-
use [dataclasses](https://docs.python.org/3/library/dataclasses.html) or
49-
[attrs](https://www.attrs.org),
50-
[structs](https://jcristharif.com/msgspec/structs.html) should feel familiar.
51-
However, they're
52-
[5-60x faster](https://jcristharif.com/msgspec/benchmarks.html#benchmark-structs>)
53-
for common operations.
44+
### **⚠️ IMPORTANT: Installation Notice**
5445

55-
All of this is included in a
56-
[lightweight library](https://jcristharif.com/msgspec/benchmarks.html#benchmark-library-size)
57-
with no required dependencies.
46+
**Do not install both `msgspec` and `msgspec-x` simultaneously!** They are conflicting packages that cannot coexist in the same environment. If you have the original `msgspec` installed, uninstall it first:
47+
48+
```bash
49+
pip uninstall msgspec
50+
pip install msgspec-x
51+
```
5852

59-
---
53+
## Dual Namespace Architecture
6054

61-
`msgspec` may be used for serialization alone, as a faster JSON or
62-
MessagePack library. For the greatest benefit though, we recommend using
63-
`msgspec` to handle the full serialization & validation workflow:
55+
`msgspec-x` provides two distinct namespaces to serve different needs:
6456

65-
**Define** your message schemas using standard Python type annotations.
57+
### 1. `msgspec` Namespace - Full Compatibility
58+
The `msgspec` namespace maintains 100% API compatibility with the original library. All your existing code will work without any changes:
6659

6760
```python
68-
>>> import msgspec
61+
import msgspec # Drop-in replacement for original msgspec
6962

70-
>>> class User(msgspec.Struct):
71-
... """A new type describing a User"""
72-
... name: str
73-
... groups: set[str] = set()
74-
... email: str | None = None
63+
class User(msgspec.Struct):
64+
name: str
65+
email: str
66+
67+
# All existing msgspec code works exactly the same
68+
user = User("alice", "alice@example.com")
69+
data = msgspec.json.encode(user)
70+
decoded = msgspec.json.decode(data, type=User)
7571
```
7672

77-
**Encode** messages as JSON, or one of the many other supported protocols.
73+
### 2. `msgspec_x` Namespace - Extended Features
74+
The `msgspec_x` namespace provides additional functionality and enhancements not available in the original library:
7875

7976
```python
80-
>>> alice = User("alice", groups={"admin", "engineering"})
77+
import msgspec_x # Extended features and community contributions
78+
79+
# Extended features will be documented as they are added
80+
# This namespace allows for innovative features without breaking compatibility
81+
```
8182

82-
>>> alice
83-
User(name='alice', groups={"admin", "engineering"}, email=None)
83+
## Core Features
8484

85-
>>> msg = msgspec.json.encode(alice)
85+
`msgspec-x` inherits all the powerful features from the original msgspec library:
8686

87-
>>> msg
88-
b'{"name":"alice","groups":["admin","engineering"],"email":null}'
87+
- 🚀 **High performance encoders/decoders** for JSON, MessagePack, YAML, and TOML
88+
- 🎉 **Support for a wide variety of Python types** with extension capabilities
89+
- 🔍 **Zero-cost schema validation** using Python type annotations
90+
-**Fast Struct type** for structured data representation
91+
- 📦 **Lightweight library** with no required dependencies
92+
93+
All protocols and performance characteristics are maintained from the original implementation.
94+
95+
## Quick Start
96+
97+
### Installation
98+
99+
```bash
100+
pip install msgspec-x
89101
```
90102

91-
**Decode** messages back into Python objects, with optional schema validation.
103+
### Basic Usage
104+
105+
Define your message schemas using standard Python type annotations:
92106

93107
```python
94-
>>> msgspec.json.decode(msg, type=User)
95-
User(name='alice', groups={"admin", "engineering"}, email=None)
108+
import msgspec
96109

97-
>>> msgspec.json.decode(b'{"name":"bob","groups":[123]}', type=User)
98-
Traceback (most recent call last):
99-
File "<stdin>", line 1, in <module>
100-
msgspec.ValidationError: Expected `str`, got `int` - at `$.groups[0]`
110+
class User(msgspec.Struct):
111+
"""A new type describing a User"""
112+
name: str
113+
groups: set[str] = set()
114+
email: str | None = None
101115
```
102116

103-
`msgspec` is designed to be as performant as possible, while retaining some of
104-
the nicities of validation libraries like
105-
[pydantic](https://pydantic-docs.helpmanual.io/). For supported types,
106-
encoding/decoding a message with `msgspec` can be
107-
[~10-80x faster than alternative libraries](https://jcristharif.com/msgspec/benchmarks.html).
117+
Encode messages as JSON or other supported protocols:
118+
119+
```python
120+
alice = User("alice", groups={"admin", "engineering"})
121+
msg = msgspec.json.encode(alice)
122+
# Output: b'{"name":"alice","groups":["admin","engineering"],"email":null}'
123+
```
124+
125+
Decode messages back into Python objects with schema validation:
126+
127+
```python
128+
# Successful decoding
129+
user = msgspec.json.decode(msg, type=User)
130+
131+
# Validation error example
132+
msgspec.json.decode(b'{"name":"bob","groups":[123]}', type=User)
133+
# Raises: ValidationError: Expected `str`, got `int` - at `$.groups[0]`
134+
```
135+
136+
## Performance
137+
138+
`msgspec-x` maintains the same exceptional performance characteristics as the original msgspec library. In benchmarks, it can be 10-80x faster than alternative libraries for encoding/decoding with validation.
108139

109140
<p align="center">
110141
<a href="https://jcristharif.com/msgspec/benchmarks.html">
111142
<img src="https://raw.githubusercontent.com/jcrist/msgspec/main/docs/source/_static/bench-validation.svg">
112143
</a>
113144
</p>
114145

115-
See [the documentation](https://jcristharif.com/msgspec/) for more information.
146+
## Community & Contributing
147+
148+
This project welcomes community contributions! Unlike the original project, we aim to provide faster review cycles and more responsive maintenance.
149+
150+
- 🐛 **Bug Reports**: Issues are addressed promptly
151+
- 🚀 **Feature Requests**: Community-driven feature development
152+
- 🔧 **Pull Requests**: Faster review and merge process
153+
- 📚 **Documentation**: Community-maintained documentation improvements
154+
155+
## Documentation
156+
157+
For detailed documentation, examples, and API references, visit:
158+
- **Project Documentation**: [https://nightsailer.github.io/msgspec-x/](https://nightsailer.github.io/msgspec-x/)
159+
- **Original msgspec docs**: [https://jcristharif.com/msgspec/](https://jcristharif.com/msgspec/) (for reference)
160+
161+
## License
116162

163+
New BSD License. See the [License File](https://github.com/nightsailer/msgspec-x/blob/main/LICENSE).
117164

118-
## LICENSE
165+
## Acknowledgments
119166

120-
New BSD. See the
121-
[License File](https://github.com/jcrist/msgspec/blob/main/LICENSE).
167+
Special thanks to Jim Crist-Harif for creating the original msgspec library. This fork exists to complement and extend his excellent work, not to replace it.

docs/source/_templates/help.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h3>Need help?</h3>
22

33
<p>
4-
Open an issue in the <a href="https://github.com/jcrist/msgspec/issues">issue tracker</a>.
5-
</p>
4+
Open an issue in the <a href="https://github.com/nightsailer/msgspec-x/issues">issue tracker</a>.
5+
</p>

docs/source/api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Structs
88

99
.. autoclass:: Struct
1010

11+
.. autoclass:: StructMeta
12+
1113
.. autofunction:: field
1214

1315
.. autofunction:: defstruct

docs/source/benchmarks.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Benchmarks
22
==========
33

44
.. note::
5+
These benchmarks are for ``msgspec-x``, a community-driven fork of the original msgspec project.
56

67
Benchmarks are *hard*.
78

0 commit comments

Comments
 (0)