Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python 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: #python #cache
ADD COMMENT
Topic
Name
2+3 =