Python takes 17 times longer to load on my Windows 7 machine than Ubuntu 14.04 running on a VM (inside Windows on the same hardware). Anaconda3 distribution is used on Windows and Ubuntu default python3.4.
From a Bash prompt (Git bash on Windows):
$ time python3 -c "pass"
returns in 0.614s on Windows and 0.036s on Linux
When packages are loaded the situation gets worse:
$ time python3 -c "import matplotlib"
returns in 6.01s on Windows and 0.189s on Linux
Spyder takes a whopping 51s to load on Windows and 1.5s on Linux.
I have not had any luck determining why I have this performance problems. Does anyone have any ideas what I should try next?
edit:
Why is python so much slower on windows? has been suggested as a possible duplicate but my performance different is far greater and not explained simply by different library dependencies and compilers. This seems to me to be related to filesystem differences.
I had suspected antivirus on-access scans but disabled the antivirus just in case.
>>> sys.path
['', 'c:\\Anaconda3\\python34.zip', 'c:\\Anaconda3\\DLLs', 'c:\\Anaconda3\\lib', 'c:\\Anaconda3', 'c:\\Anaconda3\\lib\\site-packages', 'c:\\Anaconda3\\lib\\site-packages\\Sphinx-1.2.3-py3.4.egg', 'c:\\Anaconda3\\lib\\site-packages\\cryptography-0.8-py3.4-win-amd64.egg', 'c:\\Anaconda3\\lib\\site-packages\\nose-1.3.4-py3.4.egg', 'c:\\Anaconda3\\lib\\site-packages\\win32', 'c:\\Anaconda3\\lib\\site-packages\\win32\\lib', 'c:\\Anaconda3\\lib\\site-packages\\Pythonwin', 'c:\\Anaconda3\\lib\\site-packages\\setuptools-14.3-py3.4.egg']
Update:
A fresh install of Windows 8.1 Pro on the same PC solved the problem. After reinstalling all applications and Anaconda3 Python performance is the best I have seen. Unfortunately the root cause of this issue is still unknown.
Correction:
After my IT dept installed Sophos SafeGuard encryption software and MS Endpoint Protection the problem returned. Same slow start as before. Disabling the extra software did not solve the problem so we are trying tests on other machines to trace the problem.
In a nutshell. So to sum it all up here python is slow mainly because of the two main reasons. One is dynamically types language which means, unlike in java, python has no variable declaration and this makes it quite long to compile and sometimes the variables get changed during the run without our knowledge.
On average, it can take anywhere from five to 10 weeks to learn the basics of Python programming, including object-oriented programming, basic Python syntax, data types, loops, variables, and functions.
PyInstaller's bootloader is usually quite fast in one-dir mode, but it can be much slower in one-file mode, because it depacks everything into a temporary directory. On Windows, I/O is very slow, and then you have antiviruses that will want to double check all those DLL files. PyQt itself is a non-issue.
The core that is running your python program will be blocked entirely, and your memory bus will be nearly saturated, causing other applications to seem slow as well.
The problem is solved by uninstalling Sophos SafeGuard. This is not really a satisfactory solution though since my company uses this filesystem encryption software on directories that I access daily. I have not seem any other performance problems except with Python (and apparently Ruby as well).
NOTE: Sophos SafeGuard is not antivirus software. It is an enterprise filesystem encryption system. The strange thing is that encryption is explicitly not enabled for local filesystems, such as where Python is installed.
May not be relevant to your case, but I found that running python in Windows with Sophos Safeguard and Mcafee Enteprise Antivirus that python startup times were an order of magnitude slower if python was being run as an elevated process. Switching it to run as a normal process made a dramatic difference for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With