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' #1433

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

'Solution' #1433

wants to merge 3 commits into from

Conversation

Dogober
Copy link

@Dogober Dogober commented Nov 29, 2024

No description provided.

app/main.py Outdated
cache_data = {}

def wrapper(*args) -> Callable:
if args in cache_data.keys():
Copy link

Choose a reason for hiding this comment

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

Looks like calling keys() not needed, as we already checking at dict keys

app/main.py Outdated
pass
cache_data = {}

def wrapper(*args) -> Callable:
Copy link

Choose a reason for hiding this comment

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

You can return not only callable, because your functions can return any type

Copy link
Author

Choose a reason for hiding this comment

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

Many thanks for your correction. I got it. I understood why exactly so and for what

app/main.py Outdated
Comment on lines 9 to 14
print("Getting from cache")
return cache_data[args]

cache_data[args] = func(*args)
print("Calculating new result")
return cache_data[args]
Copy link

Choose a reason for hiding this comment

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

You can try to simplify your solution to use only one return

@Dogober Dogober requested a review from L1nk3rrr December 3, 2024 05:11
Copy link

@L1nk3rrr L1nk3rrr left a comment

Choose a reason for hiding this comment

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

Well done! Minor point about what decorator accept

app/main.py Outdated Show resolved Hide resolved
@Dogober Dogober requested a review from L1nk3rrr December 4, 2024 19:58
Copy link

@petrykivd petrykivd left a comment

Choose a reason for hiding this comment

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

Nice! 😎

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