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 #1460

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Solution #1460

wants to merge 1 commit into from

Conversation

YaroslavK87
Copy link

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.

Review Summary

Great job on implementing the cache decorator! 🎉 Your code meets the task requirements and constraints effectively. Here are some key points and suggestions for improvement:

  1. Functionality: The cache decorator is implemented correctly, storing and retrieving results as expected. It also handles multiple functions simultaneously, maintaining separate caches for each.

  2. Output Messages: The messages printed by the decorator align with the task requirements, indicating when a result is retrieved from the cache or calculated anew.

  3. Code Style: Your code is efficient and well-structured, with descriptive variable names and consistent styling.

However, there are a couple of issues to address:

  • Mutable Arguments as Dictionary Keys: Using mutable types as dictionary keys can lead to issues since they are not hashable. Ensure that args are hashable (e.g., tuples of immutable types) when used as keys in the data dictionary.

  • Return Type of wrapper Function: The wrapper function should have a return type that matches the return type of the func it decorates. Currently, it is set to None, which is incorrect. Consider changing it to Any or the specific return type of func.

These issues are important for the robustness and correctness of your code. Please review the comments and make the necessary improvements. Addressing these points will help you avoid similar problems in the future and enhance your coding skills. Keep up the great work and continue learning from your experiences! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

pass
data = {}

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 wrapper function should have a return type that matches the return type of the func it decorates. Currently, it is set to None, which is incorrect. Consider changing it to Any or the specific return type of func.

data = {}

def wrapper(*args) -> None:
if args in data:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using mutable types as dictionary keys can lead to issues since they are not hashable. Ensure that args are hashable (e.g., tuples of immutable types) when used as keys in the data dictionary.

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