Skip to content

Commit

Permalink
decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
Liza Shulika committed Nov 1, 2024
1 parent 5891c38 commit 2fd07e5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
from typing import Callable
from functools import wraps


def cache(func: Callable) -> Callable:
# Write your code here
pass
a = []
@wraps(func)
def wrapper(*args, **kwargs) -> any:
result = func(*args, **kwargs)
if result not in a:
a.append(result)
print("Calculating new result")
else:
print("Getting from cache")
return wrapper

0 comments on commit 2fd07e5

Please sign in to comment.