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

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

Solution #752

wants to merge 4 commits into from

Conversation

skoval7
Copy link

@skoval7 skoval7 commented Sep 30, 2023

No description provided.

app/main.py Outdated

cache_dict = {}

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

Choose a reason for hiding this comment

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

Does it return None?

app/main.py Outdated
Comment on lines 21 to 28
@cache
def long_time_func(arg1: int, arg2: int, arg3: int) -> int:
return (arg1 ** arg2 ** arg3) % (arg1 * arg3)


@cache
def long_time_func_2(n_tuple: tuple, power: int) -> int:
return [number ** power for number in n_tuple]

Choose a reason for hiding this comment

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

Remove test funcs

app/main.py Outdated
Comment on lines 15 to 17
result = func(*args, **kwargs)
cache_dict[key] = result
return result

Choose a reason for hiding this comment

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

Avoid using additional variable here

app/main.py Outdated
return wrapper


# I wrote a new function because I deleted the old one

Choose a reason for hiding this comment

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

You don't need these functions here. Remove tests from the main file, you already have tests for the decorator, they are in the different module. Don't mix tests and main logic

app/main.py Outdated
else:
print("Calculating new result")
cache_dict[key] = func(*args, **kwargs)
return cache_dict[key]

Choose a reason for hiding this comment

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

Move return out of condition so it won't be duplicated

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.

Good job! 🌼

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