# histogrammar.util.cached¶

histogrammar.util.cached(fcn)[source]

Create a cached version of this function.

Unlike the histogrammar.util.CachedFcn constructor, this function avoids duplication (doubly wrapped objects) and commutes with histogrammar.util.named and histogrammar.util.serializable (they can be applied in either order).

Example:

f = cached(lambda x: complexFunction(x))
f(3.14)   # computes the function
f(3.14)   # re-uses the old value
f(4.56)   # computes the function again at a new point