New issue 1886: PyPy doesn't do basic loop-invariant optimizations
https://bitbucket.org/pypy/pypy/issue/1886/pypy-doesnt-do-basic-loop-invariant

mario_:

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.

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)


_______________________________________________
pypy-issue mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-issue

Reply via email to