-
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 #731
base: master
Are you sure you want to change the base?
Solution #731
Conversation
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.
Looking good, well done. Maybe no need to create extra variable in line 8 since you can just write , everything else looks good
Thank you! Yeah, when I realized that creating a variable in line 8 was redundant it was already too late ))) The pull request had been done ) |
app/main.py
Outdated
cache_dict = {} | ||
|
||
def inner(*args, **kwargs) -> None: | ||
key = args |
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.
indeed, on line 8 you can do without "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.
Yeah, it was a silly thing ))) Goin' to correct ;)
if key in cache_dict: | ||
print("Getting from cache") | ||
return cache_dict[key] | ||
else: |
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 can try to do without "else"
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.
Everything seems great, there are a few edits left
print("Calculating new result") | ||
cache_dict[args] = func(*args, **kwargs) | ||
|
||
return cache_dict[args] |
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.
try to rewrite your decorator not to have return
duplicated
app/main.py
Outdated
pass | ||
cache_dict = {} | ||
|
||
def inner(*args, **kwargs) -> [list, int]: |
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.
inner can return not only that types, it's better to use Any
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.
well done ^_^
IMHO, Decorators is a very hard topic to comprehend... ) Solving this task, I thought It was over my head