title: How to speed up python loop
body: <p>I had a look at several dicussions on several sites and none of them gave me a solution.
  This piece of code takes more than 5 seconds to run :</p>
  
  <pre><code>for i in xrange(100000000):
    pass
  </code></pre>
  
  <p>I'm working on an integer optimization problem and I have to use an  <em>O(n log n)</em> algorithm <strong>edit : an O(n²/4) algorithm, where n stands for all the matrix' items, ie, in the following code, n * m = 10000. So, for a matrix 100 * 100 with 10000 elements, it will result in nearly 25000000 iterations ...</strong>.
  Its code can be summed up like this :</p>
  
  <pre><code>m = 100
  n = 100
  for i in xrange(m):
    for j in xrange(n):
      for i2 in xrange(i + 1, m):
        for j2 in xrange(j + 1, n):
          if myarray[i][j] == myarray[i2][j2] and myarray[i2][j] == myarray[i][j2]:
            return [i, j], [i2, j2]
  </code></pre>
  
  <p>Should I give up with Python and go back to Java or to C ?</p>
  
  <p>I work with Python 2.7 and Psyco isn't available. PyPy doesn't support Tkinter out of the box and I'm using Tkinter.</p>
  
  <p>So, would they improve the looping speed ? Are there other solutions ?</p>