Python - Decorators - Cache


Cache is a way to remember all previous results to a function

from functools import cache
@cache
def factorial(n):
    return n * factorial(n-1) if n else 1