API Reference

joblib

Python library for lightweight pipelining, including memory caching of results and easy parallel loops.

Official Documentation ↗
CompatibilityThis documentation covers version v1. Check the official docs for the latest API surface.

Installation

pippip install joblib

Methods

Overview

joblib is a Python library for lightweight pipelining, offering memory-efficient persistence and easy parallel loops. This reference lists the most frequently used APIs with accurate signatures and runnable snippets.

Core APIs

  • Parallel and delayed — Runs independent function calls across processes for simple parallelism.
  • joblib.dump — Persists a Python object to disk efficiently, including large NumPy arrays.
  • joblib.load — Loads a previously dumped object, optionally memory-mapping large arrays.

Example

from joblib import Parallel, delayed

results = Parallel(n_jobs=4)(delayed(pow)(x, 2) for x in range(5))
print(results)

Notes

It uses processes by default and threads on request; choose based on whether work is CPU or IO bound. Loading untrusted dumps is unsafe.

Verification

Run a Parallel loop over several inputs and confirm the results come back in the original order.

Errors

The official API reference declares the following error types:

Security

Official security statements captured from the package documentation:

  • joblib.load 基于 pickle,可执行任意 Python 代码,禁止加载不可信来源的文件 — “WARNING: joblib.load relies on the pickle module and can therefore execute arbitrary Python code. It should therefore never be used to load files from untrusted sources.” (source: https://joblib.readthedocs.io/en/latest/generated/joblib.load.html, fetched 2026-11-08T18:29:00+08:00)

API reference evidence

Fetched from official sources on 2026-11-08T18:29:00+08:00 via WebFetch https://joblib.readthedocs.io/en/latest/generated/joblib.Parallel.html;WebFetch https://joblib.readthedocs.io/en/latest/generated/joblib.dump.html;WebFetch https://joblib.readthedocs.io/en/latest/generated/joblib.load.html.

FAQ

Why is joblib faster than pickle for arrays?
joblib stores NumPy arrays without object overhead and can memory-map them, so reads avoid loading everything into RAM.
Is joblib.dump safe against untrusted files?
No. Like pickle it can execute code on load, so only load files you produced or fully trust.
How do I use threads instead of processes?
Pass prefer="threads" to Parallel for IO-bound work where process startup would dominate.