out[np.triu_indices(a.shape[0], 1)] = dists
return out + out.T

def looping(a):
    out = np.zeros((a.shape[0], a.shape[0]))
for i in range(a.shape[0]):
    for j in range(a.shape[0]):
        out[i, j] = np.linalg.norm(a[i] - a[j])
return out
Numpy efficient one against all