Search code examples
pythonexcelpython-3.5execution-timeminiconda

Script execution time on different computers (python 3.5, miniconda)


I was faced with the following problem: on a computer (number 2) script execution time is significantly greater than on another computer (computer 1).

  • Computer 1 - i3 - 4170 CPU @ 3.7 GHz (4 core), 4GB RAM (Execution time 9.5 minutes)
  • Computer 2 - i7 - 3.07GHz (8 core), 8GB RAM (Execution time 15-17 minutes)

I use Python to process Excel files. I import for these three libraries:

  • xlrd, xlsxwriter, win32com

Why is the execution time different? How can I fix it?


Solution

  • As explained in a comment, Python uses the Global Interpreter Lock (GIL). As stated on the Wiki: "An interpreter that uses GIL always allows exactly one thread to execute at a time, even if run on a multi-core processor".

    Your i3 processor may 'only' have 4 cores instead of the 8 cores in your i7, but Python will only use 1 thread at a time: so the faster the core, the faster your script is executed. As explained on this page: "The CPU speed determines how many calculations it can perform in one second of time. The higher the speed, the more calculations it can perform, thus making the computer faster."