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
disis a disassembler for Python bytecode.Bytecodeis an implementation detail of the CPython interpreter.Eachinstruction uses 2 bytes starting in version 3.6.
See also
Claims
- id: C1 claim: dis is a disassembler for Python bytecode. source: S2 evidence: "Disassembler for Python bytecode"
- id: C2 claim: Bytecode is an implementation detail of the CPython interpreter. source: S1 evidence: "Bytecode is an implementation detail of the CPython interpreter"
- id: C3 claim: Each instruction uses 2 bytes starting in version 3.6. source: S1 evidence: "Use 2 bytes for each instruction"
Sources
- [S1] dis — Disassembler for Python bytecode. Python docs. https://docs.python.org/3/library/dis.html . License: PSF-2.0. Accessed 2026-11-18.
- [S2] dis.rst. CPython docs. https://raw.githubusercontent.com/python/cpython/main/Doc/library/dis.rst . License: PSF-2.0. Accessed 2026-11-18.
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
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.},
}
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.
- python-dis.table.json (table; CC-BY-4.0)
- python-dis.schema.json (schema; CC-BY-4.0)
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.