4 ms·
It won't help unless you call it in a specific order e.g., fib(10_000) may produce RecursionError unless you run for n in range(10_000): fib(n)
by d0mine 9y ago
It won't help unless you call it in a specific order e.g., fib(10_000) may produce RecursionError unless you run for n in range(10_000): fib(n)
- shakna 9y agoRight, it's a memoiser. You side-step some recursion through previously stored results. It works well for some class of algorithms, which coincides with quite a large subsection of problems where TCO would help formulate algorithms. There are still a bunch of limits, because you're caching results, not eliminating call frames. The first obvious drawback is performance and memory use: All results get stored in a dictionary.
- deleted 9y ago[deleted]