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

Avoid creating unnecessary objects by using generator expressions #97

Open
richcooper95 opened this issue Feb 2, 2022 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@richcooper95
Copy link

Describe the bug
In some places, objects are created unnecessarily - e.g. here:

if set(payment.keys()) != set(["amount", "currency", "type"]):

To Reproduce
n/a

Expected behavior
There are slight clarity, performance and memory gains by avoiding unnecessary creation via use of generator expressions - e.g. the above could be changed to:

if not all(k in ["amount", "currency", "type"] for k in payments.keys()):

which only creates a single list, rather than two sets and a list.

System (please complete the following information):
n/a

Additional context
Over such small sizes of list/set it won't make a tangible performance impact, so this is pretty low-priority - but I think it also makes the code a bit clearer.

@richcooper95 richcooper95 added the enhancement New feature or request label Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant