pycrefine
pycrefine turns compiled Python bytecode (.pyc files) back into readable Python source.
It reads .pyc files written by CPython 3.9 and later, has no third-party dependencies,
and works both as a command and as a library.
$ pycrefine __pycache__/report.cpython-312.pyc
def summarize(rows, limit=10):
totals = {}
for name, amount in rows:
totals[name] = (totals.get(name, 0) + amount)
return sorted(totals.items(), key=(lambda kv: -kv[1]))[:limit]
Supported Python versions
| Bytecode written by | Status | Run pycrefine under |
|---|---|---|
| Python 3.9 | supported, tested in CI | any Python 3.9 or later |
| Python 3.12, 3.14 | supported, tested in CI | the same minor version (3.12 for 3.12 bytecode) |
| Python 3.13 | works, not in CI | Python 3.13 |
| Python 3.10, 3.11 | partial: loops and exception handling often come out wrong | the same minor version |
| Python 3.8 and older | not supported |
Bytecode from 3.10 onwards can only be decompiled by the Python version that wrote it
(#94). pycrefine tells you which
version to use, and Getting started
shows how to run it under another Python in one command. Some constructs (match,
async/await, yield from) are not reconstructed yet; see
Limitations.
Install
python -m pip install pycrefine
Until the first release reaches PyPI, install from GitHub instead:
python -m pip install "git+https://github.com/sahebbiswas/pycrefine"
Or run it from a checkout without installing: python pycrefine.py file.pyc. Install
problems (command not found, externally-managed-environment, …) are covered in
Troubleshooting.
Quick start
pycrefine module.cpython-312.pyc # print the source
pycrefine module.cpython-312.pyc -o module.py # save it to a file
python -m pycrefine module.cpython-312.pyc # same, if the command is not on PATH
From Python:
import pycrefine
source = pycrefine.get_decompiler("module.cpython-312.pyc").decompile()
print(source)
Documentation
| Guide | Read it to |
|---|---|
| Getting started | install, decompile a first file, and run under the right Python version |
| Use cases | recover a project from __pycache__, batch-decompile a tree, decompile PyInstaller or in-memory code, check the output |
| Command line and Python API | look up every option, exit status and API call |
| Troubleshooting | fix setup problems and understand each error message |
| Limitations | see what is not reconstructed yet, and how to tell |
| Architecture | find your way around the code |
| Contributing | set up a development environment, run the checks, version and release |
Contributing
Bug reports with the .pyc file (or the source it came from) and the Python version that
compiled it are the most useful contribution. See CONTRIBUTING.md for
the development setup, the checks every pull request runs, and the versioning policy.
License
Metadata
Release files for pycrefine 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pycrefine-1.1.1.tar.gz | 188.7 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pycrefine-1.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 316.2 kB
Release files / pycrefine-1.1.1.tar.gz
| Download URL | pycrefine-1.1.1.tar.gz |
|---|---|
| Size | 188.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c5adc16d19d07d6dff12ce4c23136ce5be8897692e7e670ae4a7e99e3cb0504e
|
|
BLAKE2b-256 checksum How to use checksums |
cbc494e4403172014df5a70af67caaeeb1a4de7d0d63f263941a4bab2a5376e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logRelease files / pycrefine-1.1.1-py3-none-any.whl
| Download URL | pycrefine-1.1.1-py3-none-any.whl |
|---|---|
| Size | 127.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
640bb60550c97d17ded59fa4500454d0cdd07e0b371cb91f59672573eaecd9f2
|
|
BLAKE2b-256 checksum How to use checksums |
966c301103fe758f2f20120e1014a4f78c93f79a7d24f97569b14d6f5f2c8df3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logSecurity for pycrefine 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pycrefine-1.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.