Python Bytecode
In the compilation stage, Python first translates source code to a specific Intermediate Representation (IR), and then this IR is converted to machine code. The IR that Python uses is called Python Bytecode. The Python Bytecode is stored as .pyc file.
When we are given a .pyc file, we should try using a Python Bytecode decompiler to get readable source code. For newer versions of Python, use decompyle3:
GitHub - rocky/python-decompile3: Python decompiler for 3.7-3.8 Stripped down from uncompyle6 so we can refactor and start to fix up some long-standing problems
For older versions of Python, use uncompyle6:
There are some other similar tools for specific Python versions. If the decompiled output does not make sense, always try using other tools.
Copy link