Why don't people just use the compiled python file whenever they need optimization? Then the code won't have to be interpereted then compiled.
Is there something I am missing? It seems to me like a simple problem.
Why don't people just use the compiled python file whenever they need optimization? Then the code won't have to be interpereted then compiled.
Is there something I am missing? It seems to me like a simple problem.
I believe this is enough to correct your misunderstanding.
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.
source : https://docs.python.org/2/tutorial/modules.html#packages
Python is interpreted even if it's read from a pyc-file. As already said in this answer, pyc-files only speed up program starting, not execution. Commands stored into pyc-files are not machine codes, it's just python level commands that will be interpreted anyway by python interpreter. On the other hand, when you use program written in C, executable file of such program consists of machine codes, that are "interpreted" directly by CPU.
© 2022 - 2024 — McMap. All rights reserved.