title: Speed up simple distance calculation
body: <p>I'm implementing a simple code that calculates the distance between a point <code>(x_a, y_a)</code> in <code>list_A</code> and all points <code>(x_b, y_b)</code> in <code>list_B</code> and returns the minimum distance found. This is repeated for all points in <code>list_A</code>.</p>
  
  <p>A <code>MWE</code> of my code:</p>
  
  <pre><code># list_A points defined in array.
  list_A = np.array([
      [x_data_a,  # x
       y_data_a]  # y
      ], dtype=float)
  
  # list_B points defined in list.
  list_B = [[x_data_b], [y_data_b]]
  
  # Iterate through all data points in list_A
  for ind, x_a in enumerate(list_A[0][0]):
      y_a = list_A[0][1][ind]
  
      # Iterate through all points in list_B.
      dist_min = 1000.
      for ind2, x_b in enumerate(list_B[0]):
          y_b = list_B[1][ind2]
          # Find distance between points.
          dist = (x_a-x_b)**2 + (y_a-y_b)**2
          if dist &lt; dist_min:
              # Update value of min distance.
              dist_min = dist
  
      print 'Min dist to (', x_a, y_a, '): ', dist_min
  </code></pre>
  
  <p>The data is formatted like this:</p>
  
  <pre><code>list_A = [[[1.2 2.3 1.5 2.3 5.8 4.6 9.1] [2.5 1.0 4.6 2.4 7.4 1.1 3.2]]]
  
  list_B = [[1.4, 5.8, 7.9], [6.1, 1.2, 3.7]]
  </code></pre>
  
  <p>For big lists/arrays this can take quite some time to finish. Can this be sped up?</p>