-
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 #1460
base: master
Are you sure you want to change the base?
Solution #1460
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.
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:
-
Functionality: The
cache
decorator is implemented correctly, storing and retrieving results as expected. It also handles multiple functions simultaneously, maintaining separate caches for each. -
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.
-
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 thedata
dictionary. -
Return Type of
wrapper
Function: Thewrapper
function should have a return type that matches the return type of thefunc
it decorates. Currently, it is set toNone
, which is incorrect. Consider changing it toAny
or the specific return type offunc
.
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: |
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 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: |
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.
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.
No description provided.