Skip to content

Commit

Permalink
Removed redundant 'return', conditions in 'else/if' switched (to avoi…
Browse files Browse the repository at this point in the history
…d using 'not'.
  • Loading branch information
julia4406 committed Nov 26, 2024
1 parent d242dd1 commit c0004cc
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ def cache(func: Callable) -> Callable:
storage = {}

def wrapper(*args) -> Callable:
if args not in storage:
print("Calculating new result")
return storage.setdefault(args, func(*args))
else:
if args in storage:
print("Getting from cache")
return storage.get(args)
else:
print("Calculating new result")
storage.setdefault(args, func(*args))
return storage.get(args)

return wrapper

0 comments on commit c0004cc

Please sign in to comment.