File: libpickletools.tex

package info (click to toggle)
python2.5-doc 2.5-4
  • links: PTS
  • area: contrib
  • in suites: etch, etch-m68k
  • size: 7,816 kB
  • ctags: 2,720
  • sloc: python: 5,817; perl: 3,674; sh: 2,110; makefile: 1,355; xml: 836; lisp: 836; ansic: 719; sed: 2
file content (34 lines) | stat: -rw-r--r-- 1,694 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
\section{\module{pickletools} --- Tools for pickle developers.}

\declaremodule{standard}{pickletools}
\modulesynopsis{Contains extensive comments about the pickle protocols and pickle-machine opcodes, as well as some useful functions.}

\versionadded{2.3}

This module contains various constants relating to the intimate
details of the \refmodule{pickle} module, some lengthy comments about
the implementation, and a few useful functions for analyzing pickled
data.  The contents of this module are useful for Python core
developers who are working on the \module{pickle} and \module{cPickle}
implementations; ordinary users of the \module{pickle} module probably
won't find the \module{pickletools} module relevant.

\begin{funcdesc}{dis}{pickle\optional{, out=None, memo=None, indentlevel=4}}
Outputs a symbolic disassembly of the pickle to the file-like object
\var{out}, defaulting to \code{sys.stdout}.  \var{pickle} can be a
string or a file-like object.  \var{memo} can be a Python dictionary
that will be used as the pickle's memo; it can be used to perform
disassemblies across multiple pickles created by the same pickler.
Successive levels, indicated by \code{MARK} opcodes in the stream, are
indented by \var{indentlevel} spaces.
\end{funcdesc}

\begin{funcdesc}{genops}{pickle}
Provides an iterator over all of the opcodes in a pickle, returning a
sequence of \code{(\var{opcode}, \var{arg}, \var{pos})} triples.
\var{opcode} is an instance of an \class{OpcodeInfo} class; \var{arg} 
is the decoded value, as a Python object, of the opcode's argument; 
\var{pos} is the position at which this opcode is located.
\var{pickle} can be a string or a file-like object.
\end{funcdesc}