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.

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 serpycow 1.5.0

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

Source distribution (sdist)

Source distribution for serpycow 1.5.0
File Size Uploaded Provenance Actions
serpycow-1.5.0.tar.gz 39.7 kB Without provenance Details for serpycow-1.5.0.tar.gz

Release files / serpycow-1.5.0.tar.gz

Download URL serpycow-1.5.0.tar.gz
Size 39.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a0d706023e6e87f063fcfe7b807864911fbdb6658e8eb2fdc58593b35603b9da
BLAKE2b-256 checksum
How to use checksums
6d5a780d11f4e8b5a91a9a6a76a63f5654b0bd910dc245f47566b864a8020bf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.16

Security for serpycow 1.5.0

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.

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