36 questions
1360 votes
13 answers
713k views
If Python is interpreted, what are .pyc files?
Python is an interpreted language. But why does my source directory contain .pyc files, which are identified by Windows as "Compiled Python Files"?
266 votes
10 answers
578k views
Is it possible to decompile a compiled .pyc file into a .py file?
Is it possible to get some information out of the .pyc file that is generated from a .py file?
520 votes
3 answers
387k views
What do the python file extensions, .pyc .pyd .pyo stand for?
What do these python file extensions mean? .pyc .pyd .pyo What are the differences between them and how are they generated from a *.py file?
103 votes
3 answers
61k views
When are .pyc files refreshed?
I understand that ".pyc" files are compiled versions of the plain-text ".py" files, created at runtime to make programs run faster. However I have observed a few things: Upon modification of "py" ...
60 votes
4 answers
33k views
Changing the directory where .pyc files are created
Is there a way to change the directory where .pyc file are created by the Python interpreter? I saw two PEPs about that subject (0304 and 3147), but none seems to be implemented in the default ...
19 votes
3 answers
9k views
What are the limitations of distributing .pyc files?
I've started working on a commercial application in Python, and I'm weighing my options for how to distribute the application. Aside from the obvious (distribute sources with an appropriate ...
13 votes
1 answer
14k views
How can I understand a .pyc file content
I have a .pyc file. I need to understand the content of that file to know how the disassembler works of python, i.e. how can I generate a output like dis.dis(function) from .pyc file content. for e.g....
19 votes
3 answers
11k views
Why is the 'running' of .pyc files not faster compared to .py files?
I know the difference between a .py and a .pyc file. My question is not about how, but about why According to the docs: A program doesn’t run any faster when it is read from a .pyc or .pyo file ...
19 votes
3 answers
33k views
Given a python .pyc file, is there a tool that let me view the bytecode?
A Python module is automatically compiled into a .pyc file by CPython interpreter. The .pyc file, which contains the bytecode, is in binary format (marshaled code?). Is there a GUI (or command line) ...
5 votes
2 answers
19k views
pycompile for python3.2
I am running mint 13 and have python 3.2 installed using the apt-get package management system. I also have python 2.7 installed along with 3.2 The pycompile seems to be the one that packages python 2....
2 votes
3 answers
53k views
Decompiling PYC files for python 3.9.2 [duplicate]
Currently, I have a PYC file for the 3.9.2 version of python (P.S: This applies to all versions 3.9 and above). I'm trying to decompile the PYC file but it is showing an error as uncompyle6 (or rather,...
23 votes
2 answers
48k views
How hard to reverse engineer .pyd files?
After reading How do I protect Python code? , I decided to try a really simple extension module on Windows. I compiled my own extension module on Linux before, but this is the first time I compiled it ...
7 votes
1 answer
10k views
How to run a Python project using __pycache__ folder?
I want to run a Pythonic project using Python compilation (.pyc or __pycache__). In order to do that in Python2, I haven't any problem. Here is a simplified example in a Python2 project: Project tree: ...
18 votes
3 answers
30k views
How to find out the magic number for the .pyc header in Python 3
Python bytecode (.pyc) files have a header that starts with a magic number that changes between Python versions. How can I (programmatically) find out that number for the current Python version in ...
9 votes
5 answers
61k views
How can I decompile .pyc files from Python 3.10?
I did try uncompyle6, decompyle3, and others, but none of them worked with Python 3.10. Is it even possible to do this right now?