pickle5 backport for older Python

0.0.12 · abandoned · verified Fri Apr 17

pickle5 is a backport of the pickle protocol 5 (PEP 574) and other related changes, primarily for Python versions prior to 3.8. It provides the performance improvements and features of protocol 5 for Python 3.5, 3.6, and 3.7. The library is currently at version 0.0.12 and is no longer actively maintained, as its purpose has been superseded by native support in Python 3.8+.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to use `pickle5` to dump and load a Python dictionary. `pickle5` automatically uses protocol 5 by default, offering improvements over earlier pickle protocols available in older Python versions.

import pickle5
import os

data = {'name': 'Alice', 'age': 30, 'city': 'New York'}

# Dump data using pickle5 (protocol 5 is default)
with open('data.pickle5', 'wb') as f:
    pickle5.dump(data, f)

print("Data successfully pickled to data.pickle5 using pickle5.")

# Load data using pickle5
with open('data.pickle5', 'rb') as f:
    loaded_data = pickle5.load(f)

print(f"Data successfully loaded: {loaded_data}")

# Clean up
os.remove('data.pickle5')

view raw JSON →