dis3
raw JSON → 0.1.3 verified Fri May 01 auth: no python
dis3 is a backport of Python 3.5+'s `dis` module to Python 2.7. It provides the inspection and bytecode disassembly functionality of CPython 3.5+ on legacy Python 2.7. Current version: 0.1.3. Release cadence is slow, primarily for compatibility use cases.
pip install dis3 Common errors
error ImportError: No module named 'dis3' ↓
cause Package not installed or running on Python 3 where it is not needed.
fix
Run
pip install dis3 on Python 2.7. On Python 3, use the built-in dis module. Warnings
gotcha Installing dis3 on Python 3 will import the stdlib `dis` but with version-based branching; it is designed for Python 2.7, not Python 3. Use the stdlib 'dis' on Python 3. ↓
fix Only use dis3 on Python 2.7. On Python 3, use `import dis` directly.
deprecated The `CodeInfo` class and some instruction attribute names changed between Python versions; dis3 may not perfectly emulate Python 3.5+'s API in all edge cases. ↓
fix Test thoroughly if relying on specific bytecode attributes.
gotcha `Bytecode` class may have different iteration behavior than stdlib due to differences in Python 2 vs 3 bytecode. ↓
fix Refer to Python 2.7 dis documentation for expected behavior differences.
Imports
- dis
from dis3 import dis
Quickstart
from dis3 import dis
from dis3 import Bytecode, Instruction, CodeInfo
def example():
x = 1
y = 2
return x + y
dis(example)