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 229 of file AccumulatorCache.py.
230 verifyResult = AccumulatorDecorator.VERIFY_NOTHING, deepCopy = True):
231 """Function decorator, implements memoization.
234 maxSize: maximum size for the cache associated with the function (default 128)
235 verifyResult: takes two possible values
237 AccumulatorDecorator.VERIFY_NOTHING - default, the cached function result is returned with no verification
238 AccumulatorDecorator.VERIFY_HASH - before returning the cached function value, the hash of the
239 result is checked to verify if this object was not modified
240 between function calls
241 deepCopy: if True (default) a deep copy of the function result will be stored in the cache.
244 An instance of AccumulatorDecorator.
247 def wrapper_accumulator(func):
248 return AccumulatorDecorator(func, maxSize, verifyResult, deepCopy)
250 return wrapper_accumulator(func)
if func
else wrapper_accumulator