Decompile PYC and PYO bytecode files back to readable Python source code.
Drag and drop your .pyc or .pyo file or click to browse.
uncompyle6 converts Python bytecode back to source.
View the recovered Python source code in your browser.
PYC stands for Python Compiled. When Python imports a module, the interpreter compiles the source code (.py file) into bytecode and caches the result as a .pyc file. This cached bytecode allows subsequent imports to skip the compilation step, improving startup time.
In Python 3, .pyc files are stored in __pycache__ directories with filenames that include the Python version (e.g., module.cpython-39.pyc). In Python 2, .pyc files were placed alongside the .py source files.
A PYC file contains:
PYO (Python Optimized) files were created when running Python with the -O flag, which removed assert statements and __debug__ code. In Python 3.5 (PEP 488), PYO files were deprecated and replaced by PYC files with optimization level suffixes like .cpython-39.opt-1.pyc.
Both PYC and PYO files contain the same type of bytecode and can be decompiled using this tool. The optimization level does not affect decompilation — only the removed assertions and debug code will be missing from the output.
Python bytecode retains significant information about the original source code — variable names, function signatures, docstrings, line numbers, and code structure are all preserved. This makes Python decompilation much more effective than decompiling native code.
The decompiler reads the marshalled code object from the PYC file, analyzes the bytecode instructions, reconstructs control flow (if/else, loops, try/except), and generates Python source code that produces identical bytecode when recompiled.
A PYC file is compiled Python bytecode. When Python imports a module, it compiles the .py source to bytecode and caches it as a .pyc file in the __pycache__ directory for faster subsequent imports.
PYO files were compiled with Python's -O optimization flag, removing assert statements. In Python 3.5+, PYO files were replaced by PYC files with opt-1 or opt-2 suffixes. Both can be decompiled by this tool.
This tool uses uncompyle6 which supports Python bytecode from versions 2.1 through 3.8. The decompiler automatically detects the Python version from the magic number in the PYC file header.