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

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

Solution #739

wants to merge 8 commits into from

Conversation

Shatrovskyi
Copy link

No description provided.

Copy link

@kostomeister kostomeister left a comment

Choose a reason for hiding this comment

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

Nice one!

app/main.py Outdated
pass
cached = {}

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

Choose a reason for hiding this comment

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

it's better to use Any for return type annotation in this case

Copy link
Author

Choose a reason for hiding this comment

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

Got it.

app/main.py Outdated
cached = {}

def inner(*args, **kwargs) -> None:
if args in cached.keys():

Choose a reason for hiding this comment

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

no need to use keys() method here, it will search through keys by default
in similar case too

Copy link
Author

Choose a reason for hiding this comment

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

Got it! Thanks.

app/main.py Outdated
cached[args] = new_cache
print("Calculating new result")

return func(*args) if args not in cached.keys() else cached[args]

Choose a reason for hiding this comment

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

.keys() again)))

app/main.py Outdated
cached[args] = new_cache
print("Calculating new result")

return func(*args) if args not in cached.keys() else cached[args]

Choose a reason for hiding this comment

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

and may be better use just one if else statment

Copy link
Author

@Shatrovskyi Shatrovskyi Sep 29, 2023

Choose a reason for hiding this comment

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

If I replace one if statement, inner() is going to have two returns, isn't it? It's not good as well.

Copy link
Author

Choose a reason for hiding this comment

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

I've found out how to deal with that. Now It looks better.

Copy link

@LiudmylaKulinchenko LiudmylaKulinchenko 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.

4 participants