Skip to main content

Python bytecode decompiler for Python 1.0 through 3.15 (Python port of depyo.js)

Project description

depyo

Python bytecode decompiler for Python 1.0 through 3.15.

This is the Python port of depyo.js. The JavaScript version is the canonical implementation and is ~4–5× faster; this port exists so you can hack on decompilation logic in Python without a Node runtime.

Status

  • Fixture parity with JS baseline: 1236 / 1236 byte-identical (100%) across the full fixture suite (Python 1.0–3.15) as of v1.2.4. Direct stdout-vs-stdout comparison, not just snapshot match.
  • Port-only bugs: 0. Both ports also raise on the same 10 fixtures (shared opcode-handler gaps — extractContextManager, Py2.7 WITH tuple-unpack — tracked, not port defects).
  • Bytecode coverage: Python 1.0 through 3.15.

Install

pip install depyo

Or from source:

pip install -e .

Usage

depyo my_script.pyc
# → writes my_script.py next to the input

All JS CLI flags are supported (--asm, --debug, --raw, --dump, --stats, --strict, --py-version, --basedir, --out, --skip-source-gen, --skip-path, --marshal, --marshal-scan, --file-ext). Run depyo --help for the full list.

Speed

Measured across 1236 .pyc fixtures, 10 passes each:

Runtime ms/file pyc/s Relative
Node.js (V8) — depyo.js 0.47 2143 1.0×
CPython 3.12 2.48 402 5.3× slower
PyPy 3.10 3.87 259 8.3× slower

This port is ~4–5× slower than the JS original. Honest disclosure: if you need throughput, use the JS version. If you want to read and modify decompilation logic in idiomatic Python, use this one.

PyPy does not help — it's actually 35% slower than CPython on this workload. The fixtures are short-lived (fresh PycReader/PycDecompiler per file), so the JIT never warms up; hot paths are also heavy on hasattr/getattr/isinstance against polymorphic shapes, which PyPy doesn't specialize well.

Scope

Decompiles .pyc / .pyo from Python 1.0 through 3.15, including:

  • All control flow (if/elif/else, while, for, try/except/finally, with, match/case)
  • Comprehensions (list, set, dict, generator, async)
  • Functions, classes, decorators, async def, coroutines
  • PEP 695/696 generic type syntax (3.12+)
  • PEP 750 template strings (3.14+)

License

MIT — see LICENSE.

Copyright (c) 2011–2026 Sergey Kuznetsov.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

depyo-1.2.9.tar.gz (184.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

depyo-1.2.9-py3-none-any.whl (241.2 kB view details)

Uploaded Python 3

File details

Details for the file depyo-1.2.9.tar.gz.

File metadata

  • Download URL: depyo-1.2.9.tar.gz
  • Upload date:
  • Size: 184.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for depyo-1.2.9.tar.gz
Algorithm Hash digest
SHA256 faa279c96e10a464bdcd96c4c53ca753932743bdd46d8f663ee71e4ad8fc93af
MD5 0f940a91807f3b89cf2b7afde7d353fd
BLAKE2b-256 5b730382a93418ae8e6178b59c43f7a6389e3a02a856216058112c0bbd8d5270

See more details on using hashes here.

File details

Details for the file depyo-1.2.9-py3-none-any.whl.

File metadata

  • Download URL: depyo-1.2.9-py3-none-any.whl
  • Upload date:
  • Size: 241.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for depyo-1.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 e66f71f76d7ffa11cfa510205e51db97afbbc74a462c08c0c7fa847d43f97b2a
MD5 e43ca7cf776d19deebe74c7f6eaccfd0
BLAKE2b-256 389cb8b91ee2d96741d809cb1cc29a81440dc8259a34143dcd0d3b11c987cdbb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page