Serialization in Python

6 projects in Database & Storage. Most starred: orjson, marshmallow and msgspec.

For JSON, orjson is a fast Rust-backed library that natively serializes dataclasses, datetimes and NumPy arrays; it returns bytes rather than str. msgspec handles JSON and MessagePack and validates against typed Struct classes as it decodes, which makes it a fast combined parser and validator. The msgpack package implements MessagePack, a compact binary format that is a good fit for caches and internal messages. marshmallow uses explicit schemas to convert objects to and from primitive types with validation, and is common in Flask projects.

Pickle covers Python objects that JSON cannot represent. cloudpickle can serialize functions, lambdas and interactively defined classes by value, which is why distributed frameworks such as Dask, Ray and PySpark use it to ship code to workers. dill extends pickle to even more object types. Never unpickle data from an untrusted source, because loading a pickle can execute arbitrary code.

Data Formats4

msgpack

MessagePack serializer implementation for Python.

2.1kupdated 5d ago1.2.3

orjson

Fast, correct JSON library.

8.3kupdated 17d ago3.13.0

marshmallow

A lightweight library for converting complex objects to and from simple Python datatypes.

7.2kupdated 1d ago

msgspec

A fast serialization and validation library supporting JSON, MessagePack, YAML, and TOML.

4.2kupdated 1d ago0.22.0

Object Pickling2

cloudpickle

Extends pickle to functions, lambdas, and interactively defined classes, for shipping code to remote workers.

1.9kupdated 1mo ago3.1.2

dill

Extends pickle to serialize almost any object, including closures and interpreter sessions.

2.5kupdated 2d ago0.4.1
Esc

Type to search every entry. ↑↓ to move, Enter to open.