Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

dictionary cache

def memoize(func):
    cache = dict()

    def memoized_func(*args):
        if args in cache:
            return cache[args]
        result = func(*args)
        cache[args] = result
        return result

    return memoized_func
Source by dbader.org #
 
PREVIOUS NEXT
Tagged: #dictionary #cache
ADD COMMENT
Topic
Name
1+8 =