Search code examples
pythonpyinstaller

Can I make PyInstaller optimize the compilation?


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?


Solution

  • 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