[SciPy-User] efficient computation of point cloud nearest neighbors

Sturla Molden sturla at molden.no
Wed Jun 1 17:47:40 EDT 2011


Den 01.06.2011 22:07, skrev Anne Archibald:
> cKDTrees cannot currently be copied, but it would be simple to
> implement. This would save a bit of time when multiprocessing.

There is not much to save here, constructing a kd-tree is very fast 
compared to searching it. At least it is in the common case of finding k 
nearest neightbours for each point in a cloud of n points.


> That
> said, they are also immutable, so multiple threads/processes can
> happily operate on the same one.

Shared memory do not have the same base address in different processes, 
so all pointers are invalid. Thus the kd-tree must be built with integer 
offsets instead of pointers, like my first Python version did.

You'll get the same problem if you want to serialize a kd-tree: pointers 
must be saved as offsets.

os.fork() will copy-on-write on Linux though.


Sturla









More information about the SciPy-User mailing list