Pickle
Pickle is Python’s standard-library facility for serializing Python objects to byte streams and reconstructing them from those streams.
Python How-To
Pickling is Python's serialization process for converting objects into a byte stream that can be stored and later reconstructed.
- How it is used
- Preserves Python objects as binary data so costly processed data can be retrieved later.
- How deep it goes
- Works through file and bytes APIs, custom-instance restoration, compatibility limits, and a malicious-object example.
- Examples
- Uses task tuples and dictionaries, a custom Task instance, a function, and a malicious class.
- What you can do after
- Apply it via Python’s pickle module to save and restore objects while assessing compatibility and security risks.
The Quick Python Book, Fourth Edition
pickle is a Python standard-library serialization facility for converting Python objects to and from a byte stream.
- How it is used
- Persists Python data structures and program state in binary files for later restoration.
- How deep it goes
- Explains byte-stream conversion, ordered dump/load calls, supported structures, and serialization limits without implementation internals.
- Examples
- Demonstrates serializing separate scalar values, restoring them, saving a dictionary, and maintaining a disk-backed calculation cache.
- What you can do after
- Apply pickle.dump and pickle.load to save and restore Python values through binary files.
Read how The Quick Python Book, Fourth Edition explains pickle →
Fast Python: High performance techniques for large datasets
- How it is used
- Carries Python data across process boundaries and in synchronous TCP requests.
- How deep it goes
- Shows serialization and reconstruction, then details multiprocessing limits including lambda failures and transfer overhead.
- Examples
- Uses a TCP client payload and a process-pool lambda failure to illustrate serialization in practice.
- What you can do after
- Apply pickle to move data through sockets or process pools, and recognize cases requiring separate handling.
Read how Fast Python: High performance techniques for large datasets explains pickle →
Also covered in
What to know first
- PythonPython is a high-level, general-purpose, dynamically typed programming language with readable syntax and support for multiple programming paradigms.
- language modelA language model is a computational model that represents patterns in linguistic sequences to assign probabilities, predict, generate, or evaluate language.
- JSONJSON is a language-independent text-based data-interchange format that represents structured values using objects, arrays, strings, numbers, booleans, and null.
- malwareMalware is software or executable code intentionally designed to perform harmful, unauthorized, deceptive, or security-compromising actions on systems or data.
Related concepts
- byte streamproduces · A byte stream is an ordered flow of bytes representing binary data for storage, processing, transmission, or incremental reading without inherent message semantics.
- cachingused by · Caching is the temporary storage of data or computed results for reuse, reducing the work or delay of retrieving or computing them again.
- lambdacontrasts with · A lambda is an expression that defines an unnamed function, specifying its parameters and body and producing a callable value.
- JSONcontrasts with · JSON is a language-independent text-based data-interchange format that represents structured values using objects, arrays, strings, numbers, booleans, and null.
- multiprocessingused by · Multiprocessing is a programming technique that executes work in multiple operating-system processes, enabling concurrent or parallel execution across available processor resources.
Questions about pickle
What is pickle?
Pickle is Python’s standard-library facility for serializing Python objects to byte streams and reconstructing them from those streams.
Which Manning books explain pickle?
Python How-To, The Quick Python Book, Fourth Edition and Fast Python: High performance techniques for large datasets.
What should I know before learning pickle?
Manning books that teach pickle usually introduce Python, language model, JSON and malware first.
What is the difference between pickle and asyncpg Record?
Pickle is Python’s standard-library facility for serializing Python objects to byte streams and reconstructing them from those streams. An asyncpg Record is a row-like result object that provides column-value access using mapping and subscript operations.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


