← All notes

Python dis: disassemble CPython bytecode

Answer: The dis module is a disassembler for Python bytecode. Bytecode is an implementation detail of the CPython interpreter. Since version 3.6, each instruction uses 2 bytes. The interpreter can adapt bytecode for different runtime conditions, and adaptive bytecode can be shown by passing adaptive=True.

Examples

import dis
dis.dis(lambda x: x + 1)

Notes

Previously the number of bytes varied by instruction. Use dis.dis to print a human-readable listing of the bytecode for a function or code object.

Reference list

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python docs, dis — Disassembler for Python bytecode; CPython docs, dis.rst. PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python docs, dis — Disassembler for Python bytecode; CPython docs, dis.rst. PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:gz5v44eq

iinventedlight. 2026. "Python dis: disassemble CPython bytecode." iinventedlight Library, iil:note:gz5v44eq, version of 2026-11-18. https://iinventedlight.com/library/notes/python-dis/. License: CC-BY-4.0.

@misc{iil_note_gz5v44eq,
  author = {{iinventedlight}},
  title = {{Python dis: disassemble CPython bytecode}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/python-dis/},
  note = {Permanent ID iil:note:gz5v44eq. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-dis.md.