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 py-cache-decorator #1500

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

Conversation

dmytrominyaylo
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.

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:

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:

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.

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.

3 participants