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

Speedup create_list_without_duplicates function #795

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/spdx_tools/spdx/document_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ def create_document_without_duplicates(document: Document) -> Document:


def create_list_without_duplicates(list_with_potential_duplicates: List[Any]) -> List[Any]:
seen_elements = set()
list_without_duplicates = []

for element in list_with_potential_duplicates:
if element not in list_without_duplicates:
if element not in seen_elements:
seen_elements.add(element)
Copy link
Member

Choose a reason for hiding this comment

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

Instead of storing the element, you could store the element ID or similar to #792 store the astuple(element). This could solve the current issues in the CI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool! I'll look into this soon.

list_without_duplicates.append(element)

return list_without_duplicates
Loading