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
21 changes: 18 additions & 3 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
from typing import Callable
from typing import Callable, Any


def check_in_cache(run_results: dict, func: Callable, *args: Any,
**kwargs: Any, ) -> dict:
if args in run_results:
print("Getting from cache")
else:
print("Calculating new result")
run_results[args] = func(*args, **kwargs)
return run_results[args]


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

def wrapper(*args: Any, **kwargs: Any) -> dict:
cache_answer = check_in_cache(run_results, func, *args, **kwargs)
return cache_answer

return wrapper
Loading