Closed fnino closed 2 years ago
Greetings,
Thanks for the contribution. I believe this issue has come up before, and I'm glad to see a fix proposed. I will review this is as soon as possible.
For future reference: I am currently in the process of reimplementing major DEM processing functions in numba (#143). This should take care of the recursion issue, and currently appears to be resulting in 10-100x speedups across the board.
For big zones, recursion imposes an unnecessary burden on memory. The algorithm uses tail recursion, which on other languages is optimized automatically, converting it into a simple iteration. This is what I did here, because Guido von Rossum doesn't want to optimize tail recursion.
With the change, our big catchment executes with no error, faster and with less memory requirements.