dis.get_instructions()
dis.get_instructions() is a Python function in the Dis Module category. Returns an iterator over bytecode instructions for analysis. The syntax is dis.get_instructions(x, *, first_line=None, show_caches=False, adaptive=False). Returns: Iterator of Instruction objects. A typical example: for instr in dis.get_instructions(hello):
print(instr.opname, instr.argrepr)
# RESUME
# PUSH_NULL
# LOAD_GLOBAL print
# .... A close sibling is dis.dis(), which disassembles Python bytecode for a function, generator, class, method, or code object. A close sibling is dis.code_info(), which returns detailed information about a code object. A close sibling is dis.show_code(), which prints detailed code object information. A close sibling is dis.Bytecode(), which creates a Bytecode object for analyzing bytecode. More about this category: Bytecode disassembler — dis, get_instructions, code_info. Related Dis Module entries: dis.dis(), dis.code_info(), dis.show_code(), dis.Bytecode(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.