On this page
dis.Instruction
Prev: dis.get_instructions | Up: dis | Next: dis.show_code
Rel: dis.Bytecode, dis.code_info, dis.dis, dis.disassemble
Ref: docs.python.org — dis.Instruction
Tags: #public #python3 #stdlib #dis
Import
import dis
from dis import Instruction
Signature & Overview
dis.Instruction(opname, opcode, arg, argval, argrepr, offset, start_offset, starts_line, line_number, label=None, positions=None, cache_info=None)
Details for a bytecode operation.
Methods & Attributes
Instruction.baseopcode(...)— Numeric code for the base operation if operation is specialized.Instruction.baseopname(...)— Human readable name for the base operation if operation is specialized.Instruction.cache_offset(...)— Start index of the cache entries following the operation.Instruction.count(self, value, /)— Return number of occurrences of value.Instruction.end_offset(...)— End index of the cache entries following the operation.Instruction.index(self, value, start=0, stop=9223372036854775807, /)— Return first index of value.Instruction.is_jump_target(...)— True if other code jumps to here, otherwise FalseInstruction.jump_target(...)— Bytecode index of the jump target if this is a jump operation.Instruction.make(opname, arg, argval, argrepr, offset, start_offset, starts_line, line_number, label=None, positions=None, cache_info=None)—Instruction.makemethod/property.Instruction.oparg(...)— Alias for Instruction.arg.
Usage
import dis
ins = next(dis.get_instructions(lambda x: x))
assert isinstance(ins, dis.Instruction) and isinstance(ins.opname, str)
Gotchas
- Exposes
.opname,.opcode,.arg,.argval,.argrepr,.offset, and.starts_line.
REPL Inspect
from dis import Instruction
help(Instruction)
Linked from
Related notes
- tuts/python3/stdlib_module/dis/get_instructions Linked here; links to this page; shared tags: #dis, #stdlib
- tuts/python3/stdlib_module/dis/show_code 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