2 ms·
Of course in the category of 'single line' performance optimizations the most effective one is going to be: @lru_cache(1000) def fib(n): if n =
by contravariant 6y ago
Of course in the category of 'single line' performance optimizations the most effective one is going to be:
@lru_cache(1000)
def fib(n):
if n == 1 or n == 0:
return 1
return fib(n - 1) + fib(n - 2)
which lowers the time to somewhere around 20 microseconds.
I'd be interested to know if Node.js can do anything similar.