pythonqtpyqtpyinstaller

Speed up a compiled python program?


I have quite a 'heavy' python program that I would like compiled to an exe.

The program has a decent amount of imports, but using the PyQT4 framework, I load these imports whilst a splashscreen is visible.
I compile this program to a single .exe file, using pyinstaller (in cmd):

python %pycompile_file% --onefile --noconsole --icon=Icon.ico Script.pyw

However, even though the splashscreen is set to show whilst a significant amount of modules are imported (notably including sympy), and even though it shows instantly and for an adequate time frame when ran through python;
Running the produced .exe results in a serious delay before the splashscreen shows, which is only shown for a very short time before the whole program is loaded.

My suspicion is that compiling from .pyw to .exe has sped the actual 'code' up (hence why the splashscreen in shorter), but slows the actual 'beginning' of the program's execution.

How can I fix this so that the .exe does not 'start so slowly'?

(I suspect compiling to --onefile contributes greatly, but I need the .exe file to be one folder up from all the .dlls and I can not figure out how to make pyinstaller do this)

Thanks!


Windows 7
python 2.7.2
pyinstaller
PyQt4


Solution

  • Solved;

    Do not archive the .dlls into the compiled .exe.
    Keep all the files imported by the code (which you wish for the User to interact with without navigating through .dlls) one level up, and create a shortcut to the .exe that has a working directory one up from the .exe.

    You can make such a shortcut using pywin32.