Skip to main content

Serpyco: a serializer for python dataclasses

What is Serpyco ?

Serpyco is a serialization library for Python 3.6+ dataclasses that works just by defining your dataclasses:

import dataclasses
import typing

import serpyco

@dataclasses.dataclass
class Example(object):
    name: str
    num: int
    tags: typing.List[str]


serializer = serpyco.Serializer(Example)

result = serializer.dump(Example(name="foo", num=2, tags=["hello", "world"]))
print(result)

{'name': 'foo', 'num': 2, 'tags': ['hello', 'world']}

Serpyco works by analysing the dataclass fields and can recognize many types : List, Set, Tuple, Optional, Union… You can also embed other dataclasses in a definition.

The main use-case for Serpyco is to serialize objects for an API, but it can be helpful whenever you need to transform objects to/from builtin Python types.

Serpyco is tested for Python versions 3.8 to 3.12.

Features

  • Serialization and unserialization of dataclasses

  • Validation of input/output data

  • Very fast

  • Extensible through custom encoders

Installing

Serpyco is best installed via pip:

pip install serpyco

It has only 3 (4 with python 3.6 dataclasses backport) dependencies:

  • rapid-json: used for data validation and fast JSON dump/load

  • python-dateutil: used for serializing datetime objects

  • typing_inspect: used to inspect types as needed to create serializers

Documentation

Contributing

Serpyco is written using Python and Cython for parts needing speed.

Metadata

Release files for serpyco 1.3.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for serpyco 1.3.13
File Size Uploaded Provenance Actions
serpyco-1.3.13.tar.gz 41.1 kB Without provenance Details for serpyco-1.3.13.tar.gz

Release files / serpyco-1.3.13.tar.gz

Download URL serpyco-1.3.13.tar.gz
Size 41.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7ab5591aace2bc295dd68d5886619d4851e3699ae8cf7babce63c288e33904bf
BLAKE2b-256 checksum
How to use checksums
ce5568639cc29f952015a0b8afaa441fc8887a52ad409f1be9f77caa95dd4d1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Security for serpyco 1.3.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.3.13 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page