Memoisation is the recording of a function’s results in a table, usually a dictionary from arguments to results: the function looks the arguments up before computing, and stores the result before returning.
fib(5), against for the naive one. The first call on each value computes it, going down the left side; every later call on it finds it in the dictionary and returns at once, so the tree has no repeated subtree.fib(n), from figures/calls.py, with a scale that multiplies by at each mark. The naive count is multiplied by about at each step and passes million at ; the memoised count is , at .