Here is a random function, it returns its execution time. And this time is different each time, the spread is as much as 2 times (from 1.5 to 3 seconds).

from time import time from random import randint def funk(): t = time() diction = dict(zip(range(10), 'qwertyuiop')) for _ in range(1000000): _ = diction[randint(0, 9)] return round(time()- t, 4) print([funk() for _ in range(10)]) # [1.5676, 1.6232, 1.5675, 1.5516, 1.5576, 1.5513, 2.9011, 3.958, 3.9729, 3.9717] 

Why it happens? It can be decided that the search in the dictionary plays a role, how many values ​​the interpreter goes through before returning the value, but no, a million iterations drowns it out.

What is the reason?

  • First, the code should be a code, not a picture - andreymal
  • four
    Secondly, about a hundred programs still work on your computer at the same time, and each of them can take away the processor time to itself at conditionally random moments of time and thereby slow down python - andreymal
  • 2
    (I would try to run it on my own and see how much variation I have and whether the truth of other programs can affect so much, but you didn’t give the code) - andreymal February
  • one
    @MichaelTetelev programs can not be no longer open. At least you have a desktop (this is also a program, yeah), a window manager, an update center, an audio server, a dozen other system services and perhaps another antivirus - all of which can significantly affect the resulting spread - andreymal
  • one
    It turned out on my computer [1.2134, 1.2109, 1.2105, 1.2142, 1.2058, 1.2166, 1.2172, 1.2185, 1.2156, 1.2202] - we can assume that I have no variation - andreymal

0