一个更大的编译python文件(.pyc)如何比一个更轻的“.py”加载更快?

2024-04-18 17:58:48 发布

您现在位置:Python中文网/ 问答频道 /正文

python 3.5 documentation本身表示:

  • A program doesn’t run any faster when it is read from a .pyc file than when it is read from a .py file; the only thing that’s faster about .pyc files is the speed with which they are loaded.

但在我的modules文件夹中,大多数“.pyc”文件都比它对应的“.py”文件大。在


Tags: 文件therunfrompyreadisdocumentation
1条回答
网友
1楼 · 发布于 2024-04-18 17:58:48

.pyc文件已经被认为是正确的、完整的Python文件。因此,不需要对它们进行完全的词法分析和解析,只需经过几次敷衍检查就可以将它们直接加载到Python虚拟机的字节码缓存中。在

相关问题 更多 >