memoization
Memoization is a package that extends the traditional memoization macros to not only easily define such functions, but also to save the cache to disk.

What is memoization?

Memoization is a dirty little trick that can be used for a lot of problems: suppose you have a function F that is slow to calculate, or that (in the ideal case) calls itself a lot and only depends on his arguments, then you can write a wrapper function F' that saves the result of every call to F and before calling F checks if it already knows the result.

This easy trick can reduce runtimes of programs for 5e9 years to 15 minutes (Peter Van Eynde did this for a physics problem).

Use fare-memoization instead.