Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,15 @@


def cache(func: Callable) -> Callable:
# Write your code here
pass
from_cache = {}

def wrapper(*args, **kwargs) -> Callable:
if args not in from_cache:
func_result = func(*args)
print("Calculating new result")
from_cache[args] = func_result
return func_result
else:
print("Getting from cache")
return from_cache[args]
return wrapper