title: Optimization of two for-loops
body: <p>I'm trying to optimize the following code:</p>
  
  <pre><code>error1 = 0
      for point1 in p1:
          min_dist = 1000000000
          for point2 in p2:
              min_dist = min(min_dist, l2(point1, point2))
          error1 += min_dist
  </code></pre>
  
  <p>While p1,p2 are arrays of 2D points ([x,y]) </p>
  
  <p>l2 is: np.linalg.norm(np.array(p1) - np.array(p2))</p>