3

I've been using Python for 20 years on Windows, Linux and, lately, on OsX. However since MS forced me to switch from Windows 8 to Windows 10, the time required for the first run of a Python program has gone from a fraction of a second to 5-10 seconds on my 32 GB Quadcore.

Anyone knows what causes this and how to make it fast again?

Jacques de Hooge
  • 6,750
  • 2
  • 28
  • 45
  • Can you confirm that this is the case even for a trivial script, e.g. just containing a single print statement? Also, did you have any [antivirus, transparent file encryption, or other such on-access file watcher](https://stackoverflow.com/questions/29997274/python-is-very-slow-to-start-on-windows-7) application running? – Lie Ryan Nov 08 '18 at 08:37
  • Are you running the script via the .py file association, or by manually running `python.exe "path\to\script.py"`? If not the latter, please try it with a trivial script to determine a baseline on the startup time. If it's relatively quick, then the issue is likely with the .py file association. – Eryk Sun Nov 08 '18 at 11:54

1 Answers1

0

For me the time waster is all the imports. If you have any packages that are installed with -e they are especially slow to load. To measure the time, you can do this...

import time
t0=time.time()

# put all your imports here
import numpy as np 
import logging
import mystuff

print('IMPORT TIME =', time.time()-t0)
John Henckel
  • 10,274
  • 3
  • 79
  • 79