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

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

Solution #1382

wants to merge 1 commit into from

Conversation

Wenhun
Copy link

@Wenhun Wenhun commented Nov 2, 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.

Great job on implementing the caching decorator! 🎉 Your code meets all the task requirements and constraints effectively. While there are some minor improvements suggested, such as checking if args not in cache_list: directly for efficiency and ensuring that keys in cache_list are immutable, these do not impact the core functionality. Keep up the excellent work and consider these suggestions for future enhancements! 😊

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

@@ -2,5 +2,15 @@


def cache(func: Callable) -> Callable:
# Write your code here
pass
cache_list = {}

Choose a reason for hiding this comment

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

The cache_list dictionary is used to store cached results. However, using mutable types (like lists) as keys in a dictionary will raise a TypeError. Ensure that the arguments used as keys are immutable types, such as tuples.

cache_list = {}

def storage(*args, **kwargs) -> int:
if args not in cache_list.keys():

Choose a reason for hiding this comment

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

Checking if args not in cache_list.keys() is unnecessary. You can directly check if args not in cache_list: which is more efficient.

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