The dis module supports the analysis of Python byte code by
disassembling it. Since there is no Python assembler, this module
defines the Python assembly language. The Python byte code which
this module takes as an input is defined in the file
Include/opcode.h and used by the compiler and the interpreter.
Example: Given the function myfunc:
the following command can be used to get the disassembly of
2 0 LOAD_GLOBAL 0 (len)
3 LOAD_FAST 0 (alist)
6 CALL_FUNCTION 1
(The ``2'' is a line number).
The dis module defines the following functions and constants:
Disassemble the bytesource object. bytesource can denote
either a module, a class, a method, a function, or a code object.
For a module, it disassembles all functions. For a class,
it disassembles all methods. For a single code sequence, it prints
one line per byte code instruction. If no object is provided, it
disassembles the last traceback.
Disassembles the top-of-stack function of a traceback, using the last
traceback if none was passed. The instruction causing the exception
Disassembles a code object, indicating the last instruction if lasti
was provided. The output is divided in the following columns:
- the line number, for the first instruction of each line
- the current instruction, indicated as "-->",
- a labelled instruction, indicated with ">>",
- the address of the instruction,
- the operation code name,
- operation parameters, and
- interpretation of the parameters in parentheses.
The parameter interpretation recognizes local and global
variable names, constant values, branch targets, and compare
A synonym for disassemble. It is more convenient to type, and kept
for compatibility with earlier Python releases.
Sequence of operation names, indexable using the byte code.
Dictionary mapping byte codes to operation names.
Sequence of all compare operation names.
Sequence of byte codes that have a constant parameter.
Sequence of byte codes that access a free variable.
Sequence of byte codes that access an attribute by name.
Sequence of byte codes that have a relative jump target.
Sequence of byte codes that have an absolute jump target.
Sequence of byte codes that access a local variable.
Sequence of byte codes of Boolean operations.
See About this document... for information on suggesting changes.