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

OrderedSet __contains__ is O(N) #3280

Closed
1 task done
eltoder opened this issue Nov 13, 2024 · 1 comment · Fixed by #3281
Closed
1 task done

OrderedSet __contains__ is O(N) #3280

eltoder opened this issue Nov 13, 2024 · 1 comment · Fixed by #3281
Labels
⭐ enhancement Improvements for existing features 💝 good first issue Good for newcomers

Comments

@eltoder
Copy link
Contributor

eltoder commented Nov 13, 2024

Feature Description

The OrderedSet class, used in src/pdm/resolver/graph.py, stores data as a plain list. This means that __contains__ method runs in O(N) instead of O(1) like in regular sets. This can be quite inefficient if the set contains more than a few items.

Problem and Solution

The easiest is to store data as keys of a dict.

Additional Context

No response

Are you willing to contribute to the development of this feature?

  • Yes, I am willing to contribute to the development of this feature.
@eltoder eltoder added the ⭐ enhancement Improvements for existing features label Nov 13, 2024
@frostming
Copy link
Collaborator

PR welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⭐ enhancement Improvements for existing features 💝 good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants