-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #752
base: master
Are you sure you want to change the base?
Solution #752
Conversation
app/main.py
Outdated
|
||
cache_dict = {} | ||
|
||
def wrapper(*args, **kwargs) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it return None?
app/main.py
Outdated
@cache | ||
def long_time_func(arg1: int, arg2: int, arg3: int) -> int: | ||
return (arg1 ** arg2 ** arg3) % (arg1 * arg3) | ||
|
||
|
||
@cache | ||
def long_time_func_2(n_tuple: tuple, power: int) -> int: | ||
return [number ** power for number in n_tuple] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove test funcs
app/main.py
Outdated
result = func(*args, **kwargs) | ||
cache_dict[key] = result | ||
return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using additional variable here
app/main.py
Outdated
return wrapper | ||
|
||
|
||
# I wrote a new function because I deleted the old one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need these functions here. Remove tests from the main file, you already have tests for the decorator, they are in the different module. Don't mix tests and main logic
app/main.py
Outdated
else: | ||
print("Calculating new result") | ||
cache_dict[key] = func(*args, **kwargs) | ||
return cache_dict[key] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move return out of condition so it won't be duplicated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! 🌼
No description provided.