Skip to content
This repository was archived by the owner on Sep 12, 2024. It is now read-only.
This repository was archived by the owner on Sep 12, 2024. It is now read-only.

Avoid creating unnecessary objects by using generator expressions #97

@richcooper95

Description

@richcooper95

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions