Reputation: 8237
When I use PyInstaller, it builds my modules as .pyc files. But I'd prefer it to run the compilation with -OO to optmize and remove docstrings. Is this possible?
Upvotes: 8
Views: 5961
Reputation: 11
i would like to add that in cmd.exe you can type
>set PYTHONOPTIMIZE=1
>pyinstaller skript.py
the answer from Stefano M did not work in my console. i had to make two different calls.
you can check if your code is optimized by using the preprocessor directive
if __debug__:
print("optimized")
Upvotes: 1
Reputation: 4809
Since pyinstaller
is a Python script, it is sufficient to run it with optimisation activated: e.g.
PYTHONOPTIMIZE=2 pyinstaller script.py
so that during bundling .pyo
files are created instead of .pyc
Upvotes: 6