PyDocs

Nav

Python Language Services

Bytecode

dis

class (source)
  • Bytecode(x, *, first_line=None, current_offset=None, show_caches=False, adaptive=False, show_offsets=False, show_positions=False)
The bytecode operations of a piece of code

Instantiate this with a function, method, other compiled object, string of
code, or a code object (as returned by compile()).

Iterating over this yields the bytecode operations as Instruction instances.
Changed in 3.7, 3.11, 3.13, 3.14
  • 3.7: This can now handle coroutine and asynchronous generator objects.
  • 3.11: Added the show_caches and adaptive parameters.
  • 3.13: Added the show_offsets parameter
  • 3.14: Added the show_positions parameter.
Members of Bytecode

c

codeobj
The compiled code object.

d

dis
Return a formatted view of the bytecode operations.

f

first_line
The first source line of the code object (if available)
from_traceback
Construct a Bytecode from the given traceback

i

info
Return formatted information about the code object.
1 Example
>>> bytecode = dis.Bytecode(myfunc)
>>> for instr in bytecode:
...     print(instr.opname)
...
RESUME
LOAD_GLOBAL
LOAD_FAST_BORROW
CALL
RETURN_VALUE
from the Python docs
See Also
No see-alsos for dis/Bytecode
0 Notes
No notes for Bytecode