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