Rust (de)serialization for the Python pickle format.

License: Other

Language: Rust

Serde Pickle Serialization Library

Build status Latest Version


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


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

serde = "*"
serde-pickle = "*"


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


extern crate serde;
extern crate serde_pickle;

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 selects pickle version 3.
    let serialized = serde_pickle::to_vec(&map, true).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.
    let deserialized = serde_pickle::from_slice(&serialized).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).

Project Statistics

Sourcerank 8
Repository Size 97.7 KB
Stars 50
Forks 5
Watchers 2
Open issues 0
Dependencies 5
Contributors 2
Tags 7
Last updated
Last pushed

Top Contributors See all

Georg Brandl waymost

Packages Referencing this Repo

A serde-based serialization library for Python's pickle format
Latest release 0.5.1 - Updated - 50 stars

Recent Tags See all

v0.5.1 September 18, 2019
v0.5.0 March 28, 2019
v0.4.1 May 01, 2018
v0.4.0 May 14, 2017
v0.3.0 January 28, 2017
v0.2.0 July 30, 2016
v0.1.0 April 22, 2016

Something wrong with this page? Make a suggestion

Last synced: 2019-09-18 15:48:42 UTC

Login to resync this repository