cloudpickle

Extended Python pickling that can serialize lambdas, closures, and interactively defined objects

Library
PyPI
v3.1.2
1,937stars
BSD 3-Clause License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
60/100Good
Development Activity48
Maintenance24
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture80
Code Quality78
Innovation75
Learning Curve82

cloudpickle extends Python’s standard pickle module to serialize objects that pickle cannot handle on its own — lambda expressions, functions and classes defined interactively in __main__ (a script, shell, or Jupyter notebook), and closures capturing local state. It was built for cluster computing, where Python code and data need to travel over the network to remote workers, and today underpins distributed frameworks like Dask, PySpark, and Ray for exactly that reason.

What You Get

  • cloudpickle.dumps/loads — a pickle-compatible API for serializing objects standard pickle cannot, including lambdas and closures
  • Support for pickling functions and classes defined interactively in __main__ (scripts, REPL sessions, Jupyter notebooks)
  • A register_pickle_by_value/unregister_pickle_by_value API to force serialization-by-value for specific modules under active development
  • Correct handling of nested functions and closures that capture surrounding local variables
  • Compatibility layer so output can be loaded with the standard library’s pickle.loads

Common Use Cases

  • Distributed computing frameworks (Dask, PySpark, Ray) shipping user-defined functions and closures to remote worker processes
  • Serializing interactively defined functions/classes from a Jupyter notebook or REPL session so they can run on a separate worker
  • Checkpointing or transmitting callables in task-queue systems where the callable was defined in __main__ rather than an importable module
  • ML training pipelines that pass custom loss functions, lambdas, or locally-defined model classes to worker processes

Under The Hood

Architecture — The library is a thin, focused patch over the CPython pickle protocol: cloudpickle.py implements custom Pickler subclass reducers that intercept function, class, and closure-cell objects before the standard reducer would fail on them, detecting whether a given object was defined in an importable module (serialize by reference, like stock pickle) versus interactively or dynamically (serialize by value — capture bytecode, globals, and closure cells). cloudpickle_fast.py and __init__.py are thin wiring/compat shims. Tech Stack — Pure Python (99.9% of the codebase) with zero runtime dependencies, targeting compatibility across CPython and PyPy; the test suite is run via tox across supported Python versions. Code Quality — A large tests/ directory (cloudpickle_test.py, test_backward_compat.py, cloudpickle_file_test.py, cloudpickle_ipykernel_test.py) covers core serialization, cross-version backward compatibility, and notebook-specific edge cases; the README explicitly documents known limitations (e.g. functions pickled by value containing local import statements can fail), which is a good maintainability signal. API Design — The API is deliberately a drop-in replacement for pickle.dumps/pickle.loads with no new concepts to learn for basic use; advanced behavior (register_pickle_by_value) is opt-in and only needed for the specific case of live-reloading modules on distributed workers.

Used by 6 apps in this directory

Python
90%
Apache 2.0

Apache Airflow

Data Engineering

46,530

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
66
Dependency
Built with
Python90%
Updated today
Go
82%
AGPL 3.0

Beta9

Developer Tools · AI Development · Data Engineering

1,746

Run AI workloads at scale with a Pythonic serverless runtime that handles GPU inference, background jobs, and sandboxes with zero infrastructure overhead.

View details
85
Repo Health
78
Technical
69
Dependency
Built with
Go82%
Python17%
Updated today
Python
64%
MIT

Flowfile

Data Engineering

341

Visual ETL that compiles to Polars — build pipelines on a canvas, export as standalone Python, and run anywhere without platform lock-in.

View details
83
Repo Health
81
Technical
66
Dependency
Built with
Python64%
Vue19%
TypeScript16%
Updated today
Python
58%
Apache 2.0

MLflow

AI Development · Monitoring

27,573

The open source AI engineering platform for debugging, evaluating, monitoring, and optimizing production LLMs and agents at scale.

View details
97
Repo Health
86
Technical
68
Dependency
Built with
Python58%
TypeScript33%
Updated today
Rust
84%
Apache 2.0

OpenShell

AI Agents · Developer Tools

8,270

The safe, private runtime that lets autonomous AI agents operate in sandboxed environments governed by declarative YAML policies — blocking data exfiltration, credential leaks, and unauthorized network activity before they happen.

View details
84
Repo Health
81
Technical
69
Dependency
Built with
Rust84%
Updated today
Python
69%
AGPL 3.0

Tracecat

Security · Automation · AI Agents

3,771

Open-source agentic security automation platform that runs AI agents and durable workflows at scale with sandboxed execution.

View details
89
Repo Health
88
Technical
66
Dependency
Built with
Python69%
TypeScript29%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search