Is there a decorator to simply cache function return values?
Consider the following:
Consider the following:
In Java, explicitly declared Strings are interned by the JVM, so that subsequent declarations of the same String results in two pointers to the same String instance, rather than two separate (but identical) Strings.
I’m writing some moderately performance critical code in numpy.
This code will be in the inner most loop, of a computation that’s run time is measured in hours.
A quick calculation suggest that this code will be executed up something like 10^12 times, in some variations of the calculation.
I’ve been using the following memoizing decorator (from the great book Python Algorithms: Mastering Basic Algorithms in the Python Language … love it, btw).