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