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