Skip to main content

LLM-powered Python bytecode decompiler supporting multiple providers via litellm

Project description

PyChD

CI PyPI Version

LLM-powered Python bytecode decompiler. Uses litellm to support OpenAI, Anthropic, Google, Ollama, and other providers. Handles .pyc files from any Python version via xdis.

Prerequisites

Quick start

just build          # build the Docker image
just lint           # run linters (ruff, pyrefly)
just test           # run tests
just ci             # lint + test
just shell          # interactive shell inside the container

Install (pip)

pip install pychd

Usage

Compile

pychd compile <directory | file>
just compile example/python/01_example_variables.py

Decompile

pychd decompile <pyc-file> [-m MODEL] [-o OUTPUT]
# Default model (ollama/deepseek-r1)
just decompile example/__pycache__/01_example_variables.cpython-314.pyc

# Specify a model
just decompile example/__pycache__/01_example_variables.cpython-314.pyc gpt-4o

Supported -m values include any model supported by litellm:

Provider Example
OpenAI gpt-4o
Anthropic claude-sonnet-4-20250514
Google gemini/gemini-2.0-flash
Ollama (local) ollama/deepseek-r1, ollama/llama3

Large disassembly is automatically split into token-safe chunks when it exceeds the model's context window.

Validate

Compare original source against decompiled output using AST comparison:

pychd validate <original> <decompiled> [-v]
just validate example/python/ example/decompiled/

Development

All development tasks run inside Docker via just. No local Python installation is required.

just fix            # auto-fix lint issues
just test           # run pytest
just shell          # drop into the container

Examples

Example Python source files are in example/python/. Pre-generated decompiled output is in example/decompiled/.

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

pychd-1.0.0.tar.gz (74.8 kB view details)

Uploaded Source

Built Distribution

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

pychd-1.0.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file pychd-1.0.0.tar.gz.

File metadata

  • Download URL: pychd-1.0.0.tar.gz
  • Upload date:
  • Size: 74.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pychd-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9fb56dfb17cde0092b8526b310cd845367ca01802763ac2749d799fcbb80fae0
MD5 f5faea4d376cbcac2bb18f929cf1b72a
BLAKE2b-256 8452c7b855a17c2b751a90890c9a760d0f64641188366c4511b7a9b7c4b38a20

See more details on using hashes here.

Provenance

The following attestation bundles were made for pychd-1.0.0.tar.gz:

Publisher: publish.yaml on diohabara/pychd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pychd-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pychd-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pychd-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 07a9c4e6a8d60f7111863ee17e73d4c6df2a41d026655225506ee7083488f305
MD5 951fb37126009300cc5f37eed5b200a3
BLAKE2b-256 f1b8fe6760db0582c6c43dfa8ccc4eb7d1fddf006c716c123dbb397f4921f9bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pychd-1.0.0-py3-none-any.whl:

Publisher: publish.yaml on diohabara/pychd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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