Function decorator, implements memoization.
Keyword arguments:
maxSize: maximum size for the cache associated with the function (default 128)
verifyResult: takes two possible values
AccumulatorDecorator.VERIFY_NOTHING - default, the cached function result is returned with no verification
AccumulatorDecorator.VERIFY_HASH - before returning the cached function value, the hash of the
result is checked to verify if this object was not modified
between function calls
deepCopy: if True (default) a deep copy of the function result will be stored in the cache.
Returns:
An instance of AccumulatorDecorator.
Definition at line 228 of file AccumulatorCache.py.
229 verifyResult = AccumulatorDecorator.VERIFY_NOTHING, deepCopy = True):
230 """Function decorator, implements memoization.
233 maxSize: maximum size for the cache associated with the function (default 128)
234 verifyResult: takes two possible values
236 AccumulatorDecorator.VERIFY_NOTHING - default, the cached function result is returned with no verification
237 AccumulatorDecorator.VERIFY_HASH - before returning the cached function value, the hash of the
238 result is checked to verify if this object was not modified
239 between function calls
240 deepCopy: if True (default) a deep copy of the function result will be stored in the cache.
243 An instance of AccumulatorDecorator.
246 def wrapper_accumulator(func):
247 return AccumulatorDecorator(func, maxSize, verifyResult, deepCopy)
249 return wrapper_accumulator(func)
if func
else wrapper_accumulator