Memoizing recursive functions: How decorators are more elegant than I imagined

4:25pm - 4:50pm on Friday, October 4 in Madison

Abid H. Mujtaba

Watch:
https://youtu.be/OAajxA2qjIU

Description

Calculating the Fibonacci series is a classic example of writing a recursive function. However, calculating even fib(50) will tie up a modern computer for a couple of minutes. The solution to this problem is memoization, which decorators make particularly easy.

But how does a top-level decorator access the recursive call within the function itself?

The answer is both delightfully simple and extremely insightful, exposing how seemingly simple language design choices can have profound effects on its usage.

Want to edit this page?