python pyc
时间: 2023-08-28 08:20:33 浏览: 150
Python的pyc文件是Python源代码编译后生成的字节码文件,用于提高程序的执行速度。当Python解释器执行py文件时,如果存在对应的pyc文件,解释器会加载pyc文件而不是重新编译源代码。引用中提到,Python在加载pyc文件时会检查magic number,如果不一致则会拒绝加载。可以使用py_compile模块来手动将py文件编译为pyc文件,如引用所示。在运行过程中,如果遇到import语句,Python会在设定好的路径中查找对应的pyc文件或pyd文件,如果找不到,会先将对应的py文件编译为PyCodeObject,然后写入到pyc文件中,如引用所述。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [一文让你搞懂 Python 的 pyc 文件](https://blog.csdn.net/y1282037271/article/details/128531610)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [Python的pyc文件](https://blog.csdn.net/weixin_45750972/article/details/124289641)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文