On this page
  1. dis.Bytecode
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

dis.Bytecode

Up: dis | Next: dis.code_info
Rel: dis.code_info, dis.dis, dis.disassemble, dis.disco
Ref: docs.python.org — dis.Bytecode
Tags: #public #python3 #stdlib #dis


Import

import dis
from dis import Bytecode

Signature & Overview

dis.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()).

Methods & Attributes

Usage

import dis

bc = dis.Bytecode(lambda x: x + 1)
opnames = [ins.opname for ins in bc]
assert "RETURN_VALUE" in opnames

Gotchas

REPL Inspect

from dis import Bytecode
help(Bytecode)

Linked from

Related notes