stefankoegl / kdtree

A Python implementation of a kd-tree
ISC License
365 stars 118 forks source link

Modified add and search_nn to use iteration rather than recursion #5

Closed EmilHernvall closed 11 years ago

EmilHernvall commented 11 years ago

Hi,

I was looking for a kdtree that supported adding points incrementally and your implementation were the first I found that did that. I tried it out and found it worked very well, but ran into the issue that it would throw a stack overflow error when I added a large number of points. I solved this by modifying the functions I were using to descend iteratively rather than recursively. I haven't done any benchmarks, but I'm guessing that this also improves performance somewhat. It does however still pass all tests.

I'm not sure if it was a conscious choice on your part to use recursion, and if so, feel free to reject this pull request.

In any case, thanks for an excellent little library that saved me some time.

stefankoegl commented 11 years ago

Thanks for the patch! Merged.