Why is the 'running' of .pyc files not faster compared to .py files?

后端 未结 2 1311
甜味超标
甜味超标 2020-12-17 14:58

I know the difference between a .py and a .pyc file. My question is not about how, but about why Accordin

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-17 15:44

    The way the programs are run is always the same. The compiled code is interpreted.

    The way the programs are loaded differs. If there is a current pyc file, this is taken as the compiled version, so no compile step has to be taken before running the command. Otherwise the py file is read, the compiler has to compile it (which takes a little time) but then the compiled version in memory is interpreted just like in the other way.

提交回复
热议问题