Skip to contents

SymPy's cacheit decorator: cacheit(f) returns a function that remembers its results by the arguments, in the cache that clear_cache() empties.

Usage

cacheit(f)

Arguments

f

A function.

Value

The caching function.

Examples

slow_square <- function(x) { Sys.sleep(0.1); x^2 }
fast <- cacheit(slow_square)
fast(Symbol("x")); fast(Symbol("x"))
#> x^2
#> x^2