写好a.py之后直接执行python3 a.py并不会生成a.pyc,只有在b.py中import a,然后运行b.py才会生成a.pyc如果源文件没有更改的话,重新加载b模块,a.pyc也不会重新生成pyc文件本身并不能加快运行时间,但是生成.pyc文件的过程会消耗时间,所以如果pyc文件已经被加载过了,程序的时间就会减少 摘自官方文档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. 最后附上官方文档链接地址https://docs.python.org/2/tut...
写好a.py之后直接执行python3 a.py并不会生成a.pyc,只有在b.py中import a,然后运行b.py才会生成a.pyc
如果源文件没有更改的话,重新加载b模块,a.pyc也不会重新生成
pyc文件本身并不能加快运行时间,但是生成.pyc文件的过程会消耗时间,所以如果pyc文件已经被加载过了,程序的时间就会减少
摘自官方文档
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.
最后附上官方文档链接地址
https://docs.python.org/2/tut...