Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

solution #1352

wants to merge 2 commits into from

Conversation

Codoeh
Copy link

@Codoeh Codoeh commented Oct 19, 2024

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a 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:

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.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a 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)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants