On this page
  1. pickle.Pickler
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

pickle.Pickler

Prev: pickle.PickleError | Up: pickle | Next: pickle.PicklingError
Rel: pickle.dump, pickle.dumps, pickle.load, pickle.loads
Ref: docs.python.org — pickle.Pickler
Tags: #public #python3 #stdlib #pickle


Import

import pickle
from pickle import Pickler

Signature & Overview

pickle.Pickler(file, protocol=None, fix_imports=True, buffer_callback=None)

This takes a binary file for writing a pickle data stream.

Methods & Attributes

Usage

import io
import pickle

buf = io.BytesIO()
pickle.Pickler(buf, protocol=pickle.HIGHEST_PROTOCOL).dump({"k": [1, 2]})
buf.seek(0)
assert pickle.load(buf) == {"k": [1, 2]}

Gotchas

REPL Inspect

from pickle import Pickler
help(Pickler)

Linked from

Related notes