Reputation: 11860
What is the difference between these two algorithms?
Upvotes: 50
Views: 14607
Reputation: 176930
From SciPy 1.6 on, cKDTree and KDTree are identical, and you should prefer KDTree if you aren't worried about pre-1.6 compatibility.
Before SciPy 1.6, cKDTree was a subset of KDTree, implemented in C++ wrapped in Cython, so therefore faster.
Upvotes: 57
Reputation: 17236
The current (v1.8) SciPy documentation states that scipy.spatial.cKDTree is now deprecated and was replaced by the functionally-identical scipy.spatial.KDTree.
Here is the note:
cKDTree is functionally identical to KDTree. Prior to SciPy v1.6.0, cKDTree had better performance and slightly different functionality but now the two names exist only for backward-compatibility reasons. If compatibility with SciPy < 1.6 is not a concern, prefer KDTree.
Upvotes: 6
Reputation: 1014
Currently, both have almost same APIs, and cKDTree
is faster than KDTree
.
So, In the near future, SciPy developers are planning to remove KDTree
, and cKDTree
will be renamed to KDTree
in a backwards-compatible way.
Ref: Detailed SciPy Roadmap — SciPy v1.6.0.dev Reference Guide https://docs.scipy.org/doc/scipy/reference/roadmap-detailed.html#spatial
Upvotes: 2
Reputation: 1960
In a use case (5D nearest neighbor look ups in a KDTree with approximately 100K points) cKDTree is around 12x faster than KDTree.
Upvotes: 17