memo: Memoize a function.

Description Usage Arguments Author(s)

Description

Memoize a function.

This package implements a cache that can be used to avoid repeated computations of functions. The cache lookup is based on object identity (i.e. pointer equivalence) which is suited for functions like accessors or other functions that are called repeatedly on the same object. Description of memo goes here.

Usage

1
memo(fn, cache = lru_cache(5000), key = hybrid_key, ...)

Arguments

fn

A function to wrap. It should be a pure function (i.e. it should not cause side effects, and should not depend on any variables that may change.) It should not be a nonstandard-evaluating function. All arguments will be forced by the wrapper.

cache

A cache to use. Defaults to a new instance of lru_cache. Caches may be shared between memoized functions.

key

A hashing strategy. "digest_key". Other values include "pointer_key" and "hybrid_key".

...

Further arguments passed on to key.

Author(s)

Peter Meilstrup


memo documentation built on May 2, 2019, 7:01 a.m.