xdis
Python cross-version byte-code disassembler and marshal routines
What it is and what it does
xdis is a cross-version Python bytecode disassembler and manipulation library. The standard Python dis module only works on bytecode from the same Python version you are running; xdis removes that constraint, allowing you to inspect, analyze, and disassemble bytecode from any Python version on any other Python version. It can marshal-load bytecode, translate between Python version numbers and magic values, unpack and repack code objects, and provide advanced disassembly output in multiple formats.
The package is useful for reverse-engineering, bytecode analysis, writing cross-version assemblers or optimizers, and understanding how Python compiles code across different language versions. It has no runtime dependencies and is available as pure-Python wheels for most Python versions, though installation on Python versions before 3.11 requires downloading version-specific distributions from GitHub rather than PyPI.
Use it for:
- Reverse-engineer or audit Python bytecode from a different Python version than your development environment.
- Write a bytecode-level optimizer or analyzer that works across multiple Python versions.
- Translate between Python version numbers and their corresponding bytecode magic values for tooling or documentation.
- Inspect and modify code objects programmatically, such as rewriting constants or instruction sequences.
- Build a cross-version Python decompiler or bytecode assembler.
- Debug or analyze compiled Python code from production systems running a different Python version.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Disassembles Python bytecode from any Python version (1.0 through 3.13) regardless of which Python version you are running, and provides utilities for bytecode manipulation, magic-number translation, and code object introspection.
Yes, if you need to work with Python bytecode from versions other than the one you are running. The package is actively maintained, has no dependencies, and carries low install friction on modern Python. The GPL-2.0 copyleft license is a significant constraint for proprietary or closed-source use; evaluate your distribution model before adopting. For Python 3.11+, installation is straightforward; for older versions, the GitHub-only distribution model adds friction but is workable.
Install
xdis on PyPI
pip
pip install xdisuv
uv add xdispoetry
poetry add xdisInstalling xdis
Before you install
Low install friction with pure-Python wheels available for Python 2 through 3.13. Actively maintained with a recent release. For Python 3.11+, standard pip install works; older versions require downloading version-specific wheels or tarballs from GitHub Releases rather than PyPI.
License in practice
Licensed under GPL-2.0 (copyleft). Use in proprietary software requires either distributing source code or obtaining a different license; linking or bundling this library into closed-source projects carries copyleft obligations.
Quickstart
pip install xdis
import xdis.disassemble
import xdis.magics
# Disassemble bytecode from a different Python version
with open('some_bytecode.pyc', 'rb') as f:
xdis.disassemble.disassemble_file(f)
For Python versions before 3.11, you must download and install the version-specific wheel or tarball from GitHub Releases; standard PyPI pip install only works on Python 3.11+.
Verify before relying
- Whether the package can actually read and disassemble bytecode from Python 1.0 (the description claims support back to 1.0, but this may be aspirational or historical).
- Whether the 'extended' and 'extended-format' disassembly modes truly produce expression trees as claimed, or if this is limited to certain Python versions.
- Performance characteristics when processing large bytecode files or many files in sequence.
Package facts
| License | GPL-2.0 (copyleft) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 137 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 661,989/month — #5,441 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: xdis-6.3.0-py2-none-any.whl; xdis-6.3.0-py310-none-any.whl; xdis-6.3.0-py311-none-any.whl; xdis-6.3.0-py312-none-any.whl; xdis-6.3.0-py313-none-any.whl; xdis-6.3.0-py34-none-any.whl; xdis-6.3.0-py35-none-any.whl; xdis-6.3.0-py36-none-any.whl; xdis-6.3.0-py37-none-any.whl; xdis-6.3.0-py38-none-any.whl; xdis-6.3.0-py39-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
bytecodebytecode generates and modifies Python bytecode…
permissive · top 1,000 on PyPI
decompyle3Decompyle3 translates Python bytecode back into…
copyleft · top 15,000 on PyPI
uncompyle6uncompyle6 translates Python bytecode back into…
copyleft · top 15,000 on PyPI
pycnitePycnite provides pure Python parsers for Python…
permissive · top 5,000 on PyPI
evmdasmevmdasm provides a lightweight registry of…
copyleft · top 15,000 on PyPI
smdaSMDA is a recursive disassembler library that…
permissive · top 15,000 on PyPI
ethereum-dasmDisassembles Ethereum EVM bytecode into…
copyleft · top 15,000 on PyPI
pcodedmpDisassembles VBA p-code from Microsoft Office…
copyleft · top 5,000 on PyPI
pypcodepypcode provides machine code disassembly and…
permissive · top 15,000 on PyPI
vivisectVivisect is a pure-Python disassembler,…
permissive · top 15,000 on PyPI