Yacine F. answered 03/28/20
Tutor
New to Wyzant
I Will Make Easy it For You
Some experts says that it's a problem of local/global variable store times
But it can be because of opcode prediction makes the function faster.
As the other answers explain, the function uses the STORE_FAST
opcode in the loop. Here's the bytecode for the function's loop:
>> 13 FOR_ITER 6 (to 22) # get next value from iterator16 STORE_FAST 0 (x) # set local variable19 JUMP_ABSOLUTE 13 # back to FOR_ITER