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 than when it is read from a .py file; the only thing that’s faster about .pyc or .pyo files is the speed with which they are loaded.
.pyc files load imports faster. But after loading the 'running' part of .pyc files takes the same time as the 'running' part in .py files? Why is is this? I would expected that
- bit code (.pyc) is closer to the Python Virtual Machine and thus runs faster
- .py files are being compiled to .pyc before they are being executed. This takes an extra step and thus costs time.
My question: After the import part, Why does the running part of .pyc files doesn't speed up execution compared to .py files?