On this page
dis.get_instructions
Prev: dis.findlinestarts | Up: dis | Next: dis.Instruction
Rel: dis.Bytecode, dis.code_info, dis.dis, dis.disassemble
Ref: docs.python.org — dis.get_instructions
Tags: #public #python3 #stdlib #dis
Import
import dis
from dis import get_instructions
Signature & Overview
dis.get_instructions(x, *, first_line=None, show_caches=None, adaptive=False)
Iterator for the opcodes in methods, functions or code Generates a series of Instruction named tuples giving the details of each operations in the supplied code.
Usage
import dis
ins = list(dis.get_instructions(lambda a, b: a + b))
assert any(i.opname == "RETURN_VALUE" for i in ins)
Gotchas
- Programmatic alternative to parsing
dis.dis()text output.
REPL Inspect
from dis import get_instructions
help(get_instructions)
Linked from
Related notes
- tuts/python3/stdlib_module/dis/findlinestarts Linked here; links to this page; shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/Instruction Linked here; links to this page; shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/Bytecode Linked here; shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/code_info Linked here; shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/dis Linked here; shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/disassemble Linked here; shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/dis/disco shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/distb shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/findlabels shared tags: #dis, #stdlib