-
Notifications
You must be signed in to change notification settings - Fork 509
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
sets used instead of lists when membership testing #3021
sets used instead of lists when membership testing #3021
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shimwell In most cases here, you are changing an object from a list [a, b, c]
to a tuple (a, b, c)
instead of a set {a, b, c}
. For some cases (e.g., _SUBSHELLS
), it will definitely need to be a list or a tuple because the object is indexed. For many other cases, a set would be preferred if all it is being used for is membership tests. Can you go through this PR again and use sets where they are appropriate?
Sorry about this mess of a PR, I got mixed up with suggesting tuples for their immutability as I think gives us a bit more safety that using lists and suggesting using sets defined like this I shall work through these corrections and see if we index them prior to committing them |
Description
I think this will make nearly no difference on speed and we probably don't want to worry about the speed of python code. However I think sets are slightly quicker for membership checking compared to lists. Although they might be slower to create in the first place. Perhaps it makes sense to make these constants sets as they are used in the cv.checkvalue to check the user input is in the available options.
Also I noticed one defined constant that is not used
_XS_SHAPES
so I've removed thatChecklist