serpyco-rs
What it is and what it does
serpyco-rs is a serialization library for Python dataclasses that converts objects to and from built-in Python types (dict, list, etc.) or directly to/from bytes via JSON or MessagePack codecs. It analyzes dataclass field types at serializer creation time and supports a broad range of standard types—lists, tuples, optionals, enums, UUIDs, dates, decimals, unions, and nested dataclasses—along with validation of input data during deserialization.
The library is implemented in Rust for speed and offers both a simple dict-based API (dump/load) and a codec-based API for direct bytes handling. It includes features like field aliasing, custom encoders/decoders, JSON Schema generation, and query-string deserialization with type coercion. The main use case is serializing objects for APIs, though it works for any object-to-type transformation task.
Use it for:
- Serialize dataclass instances to JSON for REST API responses without intermediate dict conversion.
- Deserialize and validate incoming JSON payloads against a dataclass schema in a web framework.
- Convert Python objects to MessagePack for efficient binary storage or network transmission.
- Generate JSON Schema specifications from dataclass definitions for API documentation.
- Deserialize query string parameters into typed dataclass instances with automatic coercion.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Serializes and deserializes Python dataclasses to/from dictionaries, JSON, or MessagePack, with built-in validation and support for nested types.
Yes. serpyco-rs is actively maintained, has no known vulnerabilities, and offers strong performance for dataclass serialization. The MIT license is permissive. Install friction is moderate due to compiled wheels, but pre-built binaries are available for common platforms and Python versions 3.10–3.14. Choose it if you need fast, schema-validated serialization of dataclasses for APIs or data transformation.
Install
serpyco-rs on PyPI
pip
pip install serpyco-rsuv
uv add serpyco-rspoetry
poetry add serpyco-rsInstalling serpyco-rs
Before you install
Medium install friction due to compiled wheels for multiple platforms and Python versions (3.10–3.14). Active maintenance with a recent release and no known vulnerabilities. Lightweight runtime dependencies (attributes-doc, typing-extensions) keep the footprint small.
License in practice
MIT license (permissive); you can use this freely in commercial and private projects with minimal restrictions.
Quickstart
import dataclasses
import serpyco_rs
@dataclasses.dataclass
class Example:
name: str
num: int
serializer = serpyco_rs.Serializer(Example)
result = serializer.dump(Example(name="foo", num=2))
print(result) # {'name': 'foo', 'num': 2}
Requires Python 3.10 or later.
Verify before relying
- Whether custom encoder/decoder support covers all common field types needed for your schema.
- Performance characteristics on deeply nested or very large dataclass hierarchies.
- Compatibility with third-party dataclass libraries beyond standard library dataclasses.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 2 — attributes-doc, typing-extensions |
| Maintenance | actively maintained — 0 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 448,312/month — #6,602 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: serpyco_rs-1.22.0-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl; serpyco_rs-1.22.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; serpyco_rs-1.22.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl; serpyco_rs-1.22.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl; serpyco_rs-1.22.0-cp310-cp310-manylinux_2_17_ppc64.manylinux2014_ppc64.whl; serpyco_rs-1.22.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl; serpyco_rs-1.22.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; serpyco_rs-1.22.0-cp310-cp310-win_amd64.whl; serpyco_rs-1.22.0-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl; serpyco_rs-1.22.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; serpyco_rs-1.22.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl; serpyco_rs-1.22.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl; serpyco_rs-1.22.0-cp311-cp311-manylinux_2_17_ppc64.manylinux2014_ppc64.whl; serpyco_rs-1.22.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl; serpyco_rs-1.22.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; serpyco_rs-1.22.0-cp311-cp311-win_amd64.whl; serpyco_rs-1.22.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl; serpyco_rs-1.22.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; serpyco_rs-1.22.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl; serpyco_rs-1.22.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
databind.jsonDeserializes and serializes Python dataclasses…
permissive · top 15,000 on PyPI
pyserdeSerialize and deserialize Python dataclasses to…
permissive · top 5,000 on PyPI
databindDatabind deserializes JSON-like nested data…
permissive · top 15,000 on PyPI
srslysrsly provides a unified API for serializing…
permissive · top 1,000 on PyPI
jsonsConverts Python objects (dataclasses, attrs…
permissive · top 5,000 on PyPI
databind.coreDeserializes and serializes Python dataclasses…
permissive · top 15,000 on PyPI
cattrsConverts unstructured dictionaries into…
permissive · top 1,000 on PyPI
msgpack-pythonMessagePack serialization and deserialization…
permissive · top 5,000 on PyPI
djangorestframework-dataclassesAutomatically generates Django REST Framework…
permissive · top 5,000 on PyPI
jax-dataclassesProvides a JAX-compatible wrapper around Python…
permissive · top 15,000 on PyPI