简体   繁体   English

PythonNN.zip:是否需要PYC文件

[英]PythonNN.zip: are PYC files needed

I make Python3+Delphi app. 我制作了Python3 + Delphi应用程序。 I packed all files+dirs from Libs folder into python32.zip. 我将Libs文件夹中的所有文件和目录打包到python32.zip中。 It works. 有用。

  • Do I need PYC files (and __pycache__ dirs) in that zip? 我是否需要该zip中的PYC文件(和__pycache__目录)?
  • If I pack PYC files, will Py3k work fasteer? 如果我打包PYC文件,Py3k会更快运行吗?

You don't need to include the pyc files, no. 您不需要包含pyc文件,不。 Assuming, that is, you are adding your zip file to sys.path and importing from that (the question could use more details along those lines), the Python zipimporter will gladly compile the bytecode for you on the fly. 假设就是将zip文件添加到sys.path并从中导入(问题可能会沿着这些行使用更多详细信息),Python zipimporter会很乐意为您实时编译字节码。

You should have a little faster startup time if you include the pyc files (or for a stand-alone application you might consider including .pyo files instead, which you can make in various ways, such as running python with the -O flag). 如果包含pyc文件,则启动时间应该更快一些(或者对于独立应用程序,您可以考虑包括.pyo文件,您可以通过多种方式进行创建,例如使用-O标志运行python)。 That said this bytecode compilation is pretty fast, so depending on how many modules your application imports it might not make a noticeable difference. 也就是说,这种字节码编译非常快,因此,取决于应用程序导入的模块数量,它可能不会产生明显的变化。 Try it for yourself and see. 自己尝试一下,看看吧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM