-
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 py-cache-decorator #1500
base: master
Are you sure you want to change the base?
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.
Great job on implementing the caching mechanism! 🎉 The code meets the task requirements and constraints effectively. Just a couple of minor suggestions: consider returning a tuple instead of a list in long_time_func_2
to ensure immutability, and update the return type hint for wrapper
to Any
. Keep up the excellent work! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
app/main.py
Outdated
cache_storage = {} | ||
|
||
@wraps(func) | ||
def wrapper(*args) -> Callable: |
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 wrapper
should be Any
instead of Callable
since it returns the result of the decorated function, which can be of any type.
app/main.py
Outdated
|
||
|
||
@cache | ||
def long_time_func_2(n_tuple: tuple, power: int) -> 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.
The long_time_func_2
function returns a list, which is mutable. This contradicts the cache's requirement for immutable argument types. Consider returning a tuple instead of a list to ensure immutability.
No description provided.