Speedup create_list_without_duplicates function#795
Closed
jspeed-meyers wants to merge 1 commit intospdx:mainfrom
Closed
Speedup create_list_without_duplicates function#795jspeed-meyers wants to merge 1 commit intospdx:mainfrom
jspeed-meyers wants to merge 1 commit intospdx:mainfrom
Conversation
The current implementation includes a relatively expensive operation to check if an element is in a list. This commmit introduces a set operation that is constant time. Signed-off-by: John Speed Meyers <jsmeyers@chainguard.dev>
Author
|
It looks like there is a failure of The tests passed locally on my machine: macOS Version 14.2.1 with Python 3.11.7 -- Are the tests in the CI and the local tests different in some way? I apologize. I wouldn't have submitted this PR if I knew my local tests weren't a good representation of the CI tests. Any ideas? |
maxhbr
requested changes
Feb 15, 2024
| for element in list_with_potential_duplicates: | ||
| if element not in list_without_duplicates: | ||
| if element not in seen_elements: | ||
| seen_elements.add(element) |
Member
There was a problem hiding this comment.
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
Author
There was a problem hiding this comment.
Cool! I'll look into this soon.
Author
|
On second thought: I'm not sure this change is worth it. Sorry for the noise! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #794.