From 28c6aa70ca20820b05a094e35bb44dc75d777907 Mon Sep 17 00:00:00 2001 From: git_practic Date: Tue, 3 Dec 2024 07:08:28 +0200 Subject: [PATCH] 'keys-and-return-amadments --- app/main.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/main.py b/app/main.py index 68d006c3..4ffc38f8 100644 --- a/app/main.py +++ b/app/main.py @@ -1,16 +1,15 @@ -from typing import Callable +from typing import Any -def cache(func: Callable) -> Callable: +def cache(func: Any) -> Any: cache_data = {} - def wrapper(*args) -> Callable: - if args in cache_data.keys(): + def wrapper(*args) -> Any: + if args in cache_data: print("Getting from cache") - return cache_data[args] - - cache_data[args] = func(*args) - print("Calculating new result") + else: + cache_data[args] = func(*args) + print("Calculating new result") return cache_data[args] return wrapper