Skip to main content

Serialite

Serialite is a library serializing and deserializing arbitrarily complex objects in Python. You apply the @serializable decorator to a dataclass to automatically create to_data and from_data methods using the type annotations. Or for more control, inherit from the SerializableMixin and implement the class attribute __fields_serializer__. For even more control, inherit from the abstract base class Serializer and implement the to_data and from_data methods directly.

Basics

The abstract base class is Serializer:

class Serializer(Generic[Output]):
    def from_data(self, data: Json) -> DeserializationSuccess[Output]: ...
    def to_data(self, value: Output) -> Json: ...

The class is generic in the type of the object that it serializes. The two abstract methods from_data and to_data are the key to the whole design, which revolves around getting objects to and from JSON-serializable data, which are objects constructed entirely of bools, ints, floats, lists, and dicts. Such structures can be consumed by json.dumps to produce a string and produced by json.loads after consuming a string. By basing the serialization around JSON serializable data, complex structures can be built up or torn down piece by piece while alternatively building up complex error messages during deserialization which pinpoint the location in the structure where the bad data exist.

For new classes, it is recommended that the Serializer be implemented on the class itself. There is an abstract base class Serializable that classes can inherit from to indicate this. There is a mixin SerializableMixin that provides an implementation of from_data and to_data for any class that implements the __fields_serializer__ class attribute.

For dataclasses, it is even easier. There is a decorator serializable that inserts SerializableMixin into the list of base classes after the dataclass decorator has run and also generates __fields_serializer__ from the data class attributes.

By default, fields whose value equals their default are left out of the serialized data. Pass hide_default=False to serializable or field to always include them.

Finding the correct serializer for each type can be a pain, so serializer(cls: type) -> Serializer is provided as a convenience function. This is a single dispatch function, which looks up the serializer registered for a particular type. For example, serializer(list[float]) will return ListSerializer(FloatSerializer).

Metadata

Release files for serialite 0.6.5

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

Source distribution (sdist)

Source distribution for serialite 0.6.5
File Size Uploaded Provenance Actions
serialite-0.6.5.tar.gz 28.9 kB With provenance Details for serialite-0.6.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for serialite 0.6.5
File Interpreter ABI Platform Actions
serialite-0.6.5-py3-none-any.whl Python 3 none any Details for serialite-0.6.5-py3-none-any.whl

Total release size: 71.5 kB

Release files / serialite-0.6.5.tar.gz

Download URL serialite-0.6.5.tar.gz
Size 28.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bc34d6453f41e7aaa4f3f6460eea2739273a1da40a38e30890b06e4c5c76cf2c
BLAKE2b-256 checksum
How to use checksums
82c849571c56ec3ac91e31ac4d6359836c8f1bb3a82b3a184946a7316fcb4503
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Release files / serialite-0.6.5-py3-none-any.whl

Download URL serialite-0.6.5-py3-none-any.whl
Size 42.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eaea63472e8419a1288668b5a37f161ceb2c095673eb8d5ccc2347528d2ce433
BLAKE2b-256 checksum
How to use checksums
4720338cf19eed5b6af1503a87b48254c7a24efa756494015961600be93ef75e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Security for serialite 0.6.5

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for serialite-0.6.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

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