Skip to content

Commit

Permalink
'Improving'
Browse files Browse the repository at this point in the history
  • Loading branch information
fedorov-s-od committed Sep 29, 2023
1 parent 5f4dbd3 commit c234964
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
def cache(func: Callable) -> Callable:
cache_dict = {}

def inner(*args, **kwargs) -> None:
key = args
def inner(*args, **kwargs) -> [list, int]:

if key in cache_dict:
if args in cache_dict:
print("Getting from cache")
return cache_dict[key]
else:
print("Calculating new result")
result = func(*args, **kwargs)
cache_dict[key] = result
return cache_dict[args]

return result
print("Calculating new result")
cache_dict[args] = func(*args, **kwargs)

return cache_dict[args]

return inner

0 comments on commit c234964

Please sign in to comment.