Why cdist from scipy.spatial.distance is so fast?
问题 I wanted to create a distance proximity matrix for 10060 records/ points, where each record/point has 23 attributes using euclidean distance as metric. I wrote code using nested for loops to calculate distance between each point(leading to (n(n-1))/2) computations). It took a long time(about 8 minutes). When I used cdist it took so much lesser time( just 3 seconds !!! ). When I looked at the source code, the cdist also uses nested for loops and moreover it makes n^2 computations(which is