diff --git a/app/main.py b/app/main.py index 68287892f..75e66928c 100644 --- a/app/main.py +++ b/app/main.py @@ -1,6 +1,15 @@ -from typing import Callable +from typing import Callable, Any def cache(func: Callable) -> Callable: - # Write your code here - pass + result = {} + + def inner(*args) -> Any: + if args in result: + print("Getting from cache") + return result[args] + print("Calculating new result") + res = func(*args) + result[args] = res + return res + return inner