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:
def myfunc(alist):
return len(alist)
the following command can be used to get the disassembly of
myfunc():
Disassemble the bytesource object. bytesource can denote
either a class, a method, a function, or a code object. 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
is indicated.