-
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 #1352
base: master
Are you sure you want to change the base?
solution #1352
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.
The return type hint for the 'wrapper' function needs to be corrected to match the return type of 'func'. This is important to ensure the code's functionality is accurate. Please update this, and your code will be good to go! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
app/main.py
Outdated
cache = {} | ||
|
||
@wraps(func) | ||
def wrapper(*args) -> 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.
The return type hint for the 'wrapper' function should match the return type of 'func'. Currently, it is set to 'None', which is incorrect if 'func' returns a value.
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.
Great job on implementing the function! 🎉 While the code works, remember to optimize by returning the stored result directly to enhance efficiency. Keep up the good work and make sure to address this in future projects to improve your coding skills. Keep learning and growing!
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
return cache[args] | ||
else: | ||
print("Calculating new result") | ||
cache[args] = func(*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.
Code Efficiency: You are calling func(*args)
and storing the result in cache[args]
. Instead of calling cache[args]
again in the return statement, you can directly return the stored result. This avoids accessing the dictionary twice unnecessarily.
No description provided.