class dis.Bytecode(x, *, first_line=None, current_offset=None)
Analyse the bytecode corresponding to a function, generator, method, string of source code, or a code object (as returned by compile()
).
This is a convenience wrapper around many of the functions listed below, most notably get_instructions()
, as iterating over a Bytecode
instance yields the bytecode operations as Instruction
instances.
If first_line is not None, it indicates the line number that should be reported for the first source line in the disassembled code. Otherwise, the source line information (if any) is taken directly from the disassembled code object.
If current_offset is not None, it refers to an instruction offset in the disassembled code. Setting this means dis()
will display a “current instruction” marker against the specified opcode.
-
classmethod from_traceback(tb)
-
Construct a
Bytecode
instance from the given traceback, setting current_offset to the instruction responsible for the exception.
-
codeobj
-
The compiled code object.
-
first_line
-
The first source line of the code object (if available)
-
dis()
-
Return a formatted view of the bytecode operations (the same as printed by
dis.dis()
, but returned as a multi-line string).
-
info()
-
Return a formatted multi-line string with detailed information about the code object, like
code_info()
.
Please login to continue.