This is a cute example, but it misses the mark. The efficient way to do fast nearest neighbor search is with a search tree (e.g., KDTree or BallTree), which brings down query time from linear to logarithmic in the number of items.
http://www.frankmcsherry.org/graph/scalability/cost/2015/01/...