I know the difference between a .py and a .pyc file. My question is not about how, but about why Accordin
When you run a .py file, it is first compiled to bytecode, then executed. The loading of such a file is slower because for a .pyc, the compilation step has already been performed, but after loading, the same bytecode interpretation is done.
In pseudocode, the Python interpreter executes the following algorithm:
code = load(path)
if path.endswith(".py"):
code = compile(code)
run(code)