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

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

Solution #731

wants to merge 3 commits into from

Conversation

fedorov-s-od
Copy link

IMHO, Decorators is a very hard topic to comprehend... ) Solving this task, I thought It was over my head

Copy link

@Naz-iv Naz-iv left a comment

Choose a reason for hiding this comment

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

Looking good, well done. Maybe no need to create extra variable in line 8 since you can just write , everything else looks good

@fedorov-s-od
Copy link
Author

Looking good, well done. Maybe no need to create extra variable in line 8 since you can just write , everything else looks good

Thank you! Yeah, when I realized that creating a variable in line 8 was redundant it was already too late ))) The pull request had been done )

app/main.py Outdated
cache_dict = {}

def inner(*args, **kwargs) -> None:
key = args

Choose a reason for hiding this comment

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

indeed, on line 8 you can do without "key"

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, it was a silly thing ))) Goin' to correct ;)

if key in cache_dict:
print("Getting from cache")
return cache_dict[key]
else:
Copy link

@MiskoRuslan MiskoRuslan Sep 29, 2023

Choose a reason for hiding this comment

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

you can try to do without "else"

Copy link

@MiskoRuslan MiskoRuslan left a comment

Choose a reason for hiding this comment

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

Everything seems great, there are a few edits left

print("Calculating new result")
cache_dict[args] = func(*args, **kwargs)

return cache_dict[args]

Choose a reason for hiding this comment

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

try to rewrite your decorator not to have return duplicated

app/main.py Outdated
pass
cache_dict = {}

def inner(*args, **kwargs) -> [list, int]:

Choose a reason for hiding this comment

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

inner can return not only that types, it's better to use Any

Copy link

@fsocie7y fsocie7y 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 ^_^

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.

5 participants