.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.
  • When a script is run by giving its name on the command line, the bytecode for the script is never written to a ‘.pyc’ or ‘.pyo’ file. Thus, the startup time of a script may be reduced by moving most of its code to a module and having a small bootstrap script that imports that module. It is also possible to name a ‘.pyc’ or ‘.pyo’file directly on the command line.

   在你 import 别的 py 文件时,那个 py 文件会被存一份 pyc 加速下次装载。而主文件因为只需要装载一次就没有存pyc,你可以写两个 a.py 和 b.py,一个 import 另一个试试看。  

   作者:李璜
   链接:https://www.zhihu.com/question/30296617/answer/47512467
   来源:知乎

 

   .pcy是预编译后的字节码(Not机器码),当import其他py文件时,那个py文件会在自己目录产生__pycache__/xx.pyc文件,相当于先编译了要导入的py文件。

转载于:https://www.cnblogs.com/yangdadahome/p/8111109.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值