Hi all,<br><br>I'm facing a strange issue in Python execution speed. I'm running the following test script:<br><br>---------------------------------8<-----------------------------------------<br><br>dim = 1000<br>
iteration = 100000<br><br>list1 = []<br>list2 =  []<br><br>for i in range(dim):<br>    list1.append(float(i))<br>    list2.append(float(i) * 0.264)<br><br>for k in range(iteration):<br>    for j in range(dim):<br>        ris = 0<br>
        ris = ris + list1[j] + list2[j]<br><br>---------------------------------8<-----------------------------------------<br><br>which runs in about 80 seconds on my local hardware (mean of multiple execution)<br>If I move the whole code into a function and call this latter the execution time drops to about 45 seconds.<br>
<br>What is the reason of this improvement?<br><br>Thank you very much in advance.<br><br clear="all">Leonardo Giordani<br><br>