1 | \section{\module{pickletools} --- Tools for pickle developers.}
|
---|
2 |
|
---|
3 | \declaremodule{standard}{pickletools}
|
---|
4 | \modulesynopsis{Contains extensive comments about the pickle protocols and pickle-machine opcodes, as well as some useful functions.}
|
---|
5 |
|
---|
6 | \versionadded{2.3}
|
---|
7 |
|
---|
8 | This module contains various constants relating to the intimate
|
---|
9 | details of the \refmodule{pickle} module, some lengthy comments about
|
---|
10 | the implementation, and a few useful functions for analyzing pickled
|
---|
11 | data. The contents of this module are useful for Python core
|
---|
12 | developers who are working on the \module{pickle} and \module{cPickle}
|
---|
13 | implementations; ordinary users of the \module{pickle} module probably
|
---|
14 | won't find the \module{pickletools} module relevant.
|
---|
15 |
|
---|
16 | \begin{funcdesc}{dis}{pickle\optional{, out=None, memo=None, indentlevel=4}}
|
---|
17 | Outputs a symbolic disassembly of the pickle to the file-like object
|
---|
18 | \var{out}, defaulting to \code{sys.stdout}. \var{pickle} can be a
|
---|
19 | string or a file-like object. \var{memo} can be a Python dictionary
|
---|
20 | that will be used as the pickle's memo; it can be used to perform
|
---|
21 | disassemblies across multiple pickles created by the same pickler.
|
---|
22 | Successive levels, indicated by \code{MARK} opcodes in the stream, are
|
---|
23 | indented by \var{indentlevel} spaces.
|
---|
24 | \end{funcdesc}
|
---|
25 |
|
---|
26 | \begin{funcdesc}{genops}{pickle}
|
---|
27 | Provides an iterator over all of the opcodes in a pickle, returning a
|
---|
28 | sequence of \code{(\var{opcode}, \var{arg}, \var{pos})} triples.
|
---|
29 | \var{opcode} is an instance of an \class{OpcodeInfo} class; \var{arg}
|
---|
30 | is the decoded value, as a Python object, of the opcode's argument;
|
---|
31 | \var{pos} is the position at which this opcode is located.
|
---|
32 | \var{pickle} can be a string or a file-like object.
|
---|
33 | \end{funcdesc}
|
---|
34 |
|
---|