Consider the following code:
X = rand.rand(10, 2) differences = X[:, np.newaxis, :] - X[np.newaxis, :, :] differences = X[:, np.newaxis, :] - X[np.newaxis, :,