PyPy doesn't do basic loop-invariant optimizations
Created originally on Bitbucket by Anonymous
This code can be sped up about 25% by realizing that a[i] is constant in the inner loop. I know threading potentially invalidates such optimizations but there are some options to work around that.
#!python n = 10**4 a = [list(range(n))]*n s = 0 for i in range(n): #ai = a[i] for j in range(n): s += a[i][j] print(s)