Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

lru_cache

from functools import lru_cache


# store a maximum of 32 value cached
@lru_cache(maxsize=32)
def fib(n):
    if n < 2:
        return n
    return fib(n-1) + fib(n-2)

#clear cache
fib.cache_clear()
Source by codefreelance.net #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
5+2 =