On this page
pickle.dumps
Prev: pickle.dump | Up: pickle | Next: pickle.load
Rel: pickle.dump, pickle.load, pickle.loads, pickle.PickleBuffer
Ref: docs.python.org — pickle.dumps
Tags: #public #python3 #stdlib #pickle
Import
import pickle
from pickle import dumps
Signature & Overview
pickle.dumps(obj, protocol=None, *, fix_imports=True, buffer_callback=None)
Return the pickled representation of the object as a bytes object.
Usage
import pickle
blob = pickle.dumps((1, "two", {3}), protocol=pickle.HIGHEST_PROTOCOL)
assert pickle.loads(blob) == (1, "two", {3})
Gotchas
- Never unpickle untrusted bytes: Unpickling can execute arbitrary code.
REPL Inspect
from pickle import dumps
help(dumps)
Linked from
- tuts/python3/stdlib_module/pickle
- tuts/python3/stdlib_module/pickle/dump
- tuts/python3/stdlib_module/pickle/load
- tuts/python3/stdlib_module/pickle/loads
- tuts/python3/stdlib_module/pickle/PickleBuffer
- tuts/python3/stdlib_module/pickle/PickleError
- tuts/python3/stdlib_module/pickle/Pickler
- tuts/python3/stdlib_module/pickle/PicklingError
- tuts/python3/stdlib_module/pickle/Unpickler
- tuts/python3/stdlib_module/pickle/UnpicklingError
Related notes
- tuts/python3/stdlib_module/pickle/dump Linked here; links to this page; shared tags: #pickle, #stdlib
- tuts/python3/stdlib_module/pickle/load Linked here; links to this page; shared tags: #pickle, #stdlib
- tuts/python3/stdlib_module/pickle/loads Linked here; links to this page; shared tags: #pickle, #stdlib
- tuts/python3/stdlib_module/pickle/PickleBuffer Linked here; links to this page; shared tags: #pickle, #stdlib
- tuts/python3/stdlib_module/pickle Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/pickle/PickleError links to this page; shared tags: #pickle, #stdlib
- tuts/python3/stdlib_module/pickle/Pickler links to this page; shared tags: #pickle, #stdlib
- tuts/python3/stdlib_module/pickle/PicklingError links to this page; shared tags: #pickle, #stdlib
- tuts/python3/stdlib_module/pickle/Unpickler links to this page; shared tags: #pickle, #stdlib
- tuts/python3/stdlib_module/pickle/UnpicklingError links to this page; shared tags: #pickle, #stdlib