blob: 0fe76ff7b2a44165c106c2f119ec1ac55818cc89 [file] [log] [blame]
Andrew M. Kuchling8def8762004-08-07 16:53:59 +00001\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
6This module contains various constants relating to the intimate
7details of the \refmodule{pickle} module, some lengthy comments about
8the implementation, and a few useful functions for analyzing pickled
9data. The contents of this module are useful for Python core
10developers who are working on the \module{pickle} and \module{cPickle}
11implementations; ordinary users of the \module{pickle} module probably
12won't find the \module{pickletools} module relevant.
13
14\begin{funcdesc}{dis}{pickle\optional{, out=None, memo=None, indentlevel=4}}
15Outputs a symbolic disassembly of the pickle to the file-like object
16\var{out}, defaulting to \code{sys.stdout}. \var{pickle} can be a
17string or a file-like object. \var{memo} can be a Python dictionary
18that will be used as the pickle's memo; it can be used to perform
19disassemblies across multiple pickles created by the same pickler.
20Successive levels, indicated by \code{MARK} opcodes in the stream, are
21indented by \var{indentlevel} spaces.
22\end{funcdesc}
23
24\begin{funcdesc}{genops}{pickle}
25Provides an iterator over all of the opcodes in a pickle, returning a
26sequence of \code{(\var{opcode}, \var{arg}, \var{pos})} triples.
27\var{opcode} is an instance of an \class{OpcodeInfo} class; \var{arg}
28is the decoded value, as a Python object, of the opcode's argument;
29\var{pos} is the position at which this opcode is located.
30\var{pickle} can be a string or a file-like object.
31\end{funcdesc}
32