An alternative solution that I discovered a year ago. My problem was that I had a list of 2D points lying in an image. I wanted to calculate the distance to the nearest point for every pixel - somewhat similar to a Voronoi diagram except I needed the distances as well as the cells.<p>When I asked Stackoverflow, having tried Kdtree, someone suggested a simple brute force solution in OpenCL (using the pyopencl library):<p><a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;24020409&#x2F;producing-a-nearest-neighbour-distance-map-for-a-set-of-points" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;24020409&#x2F;producing-a-nea...</a><p>Scipy&#x27;s KDtree took around 30 seconds per 1MP image. The OpenCL solution took 50ms (at the expense of my screen locking up)!<p>As the response said: &quot;And the improvement was quite good.&quot;, no kidding.