我可以让 PyInstaller 优化编译吗?

xor*_*yst 6 python pyinstaller

当我使用 PyInstaller 时,它将我的模块构建为 .pyc 文件。但我更喜欢它使用 -OO 运行编译来优化和删除文档字符串。这可能吗?

Ste*_*o M 4

由于pyinstaller它是一个Python脚本,因此在激活优化的情况下运行它就足够了:例如

PYTHONOPTIMIZE=2 pyinstaller script.py
Run Code Online (Sandbox Code Playgroud)

这样在捆绑过程中.pyo会创建文件而不是.pyc