#pickle #serialization #serde #python

pickled

A serde-based serialization library for Python's pickle format

7 releases (1 stable)

Uses new Rust 2024

new 2.0.0-alpha6 Apr 9, 2026
2.0.0-alpha5 Apr 8, 2026
2.0.0-alpha3 Oct 5, 2025
1.2.0 Jan 3, 2024

#607 in Encoding

Download history 46/week @ 2025-12-17 15/week @ 2025-12-24 11/week @ 2026-01-14 13/week @ 2026-01-21 3/week @ 2026-01-28 18/week @ 2026-02-04 69/week @ 2026-02-11 57/week @ 2026-02-18 141/week @ 2026-02-25 66/week @ 2026-03-04 108/week @ 2026-03-11 77/week @ 2026-03-18 31/week @ 2026-03-25 37/week @ 2026-04-01

263 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

350KB
5.5K SLoC

Serde Pickle Serialization Library

This is a fork of https://crates.io/crates/serde-pickle with the following notable differences:

  1. Support for recursive data structures
  2. Support for refcounted data objects
  3. Support for treating _reconstructor objects as dictionaries
  4. variantly support for Value types to make working with pickled data easier.

THIS CRATE IS NOT INTENDED FOR WIDE USE, AND I MAKE NO GUARANTEES ABOUT BEING A GOOD PROJECT MAINTAINER (although I will not be evil, I just cannot guarantee that I can support this crate)

Latest Version

Documentation

This crate is a Rust library for parsing and generating Python pickle streams. It is built upon Serde, a high performance generic serialization framework.

Installation

This crate works with Cargo and can be found on crates.io with a Cargo.toml like:

[dependencies]
serde = "1.0"
pickled = "1.0"

Requirements

Minimum supported Rust version is 1.41.1.

Usage

As with other serde serialization implementations, this library provides toplevel functions for simple en/decoding of supported objects.

Example:

use std::collections::BTreeMap;

fn main() {
    let mut map = BTreeMap::new();
    map.insert("x".to_string(), 1.0);
    map.insert("y".to_string(), 2.0);

    // Serialize the map into a pickle stream.
    // The second argument are serialization options.
    let serialized = pickled::to_vec(&map, Default::default()).unwrap();

    // Deserialize the pickle stream back into a map.
    // Because we compare it to the original `map` below, Rust infers
    // the type of `deserialized` and lets serde work its magic.
    // The second argument are additional deserialization options.
    let deserialized = pickled::from_slice(&serialized, Default::default()).unwrap();
    assert_eq!(map, deserialized);
}

Serializing and deserializing structs and enums that implement the serde-provided traits is supported, and works analogous to other crates (using serde_derive).

Dependencies

~3–8.5MB
~161K SLoC