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?
[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