title: Fastest pairwise distance metric in python
body: <p>I have an 1D array of numbers, and want to calculate all pairwise euclidean distances. I have a method (thanks to SO) of doing this with broadcasting, but it's inefficient because it calculates each distance twice. And it doesn't scale well.</p>
  
  <p>Here's an example that gives me what I want with an array of 1000 numbers. </p>
  
  <pre><code>import numpy as np
  import random
  r = np.array([random.randrange(1, 1000) for _ in range(0, 1000)])
  dists = np.abs(r - r[:, None])
  </code></pre>
  
  <p>What's the fastest implementation in scipy/numpy/scikit-learn that I can use to do this, given that it has to scale to situations where the 1D array has >10k values. </p>
  
  <p>Note: the matrix is symmetric, so I'm guessing that it's possible to get at least a 2x speedup by addressing that, I just don't know how.</p>