-
Notifications
You must be signed in to change notification settings - Fork 116
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
Optimizing ListConfig.__contains__ #530
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.
Just not sure about returning False for missing/None
], | ||
) | ||
def test_list_iter(lst: List[Any], benchmark: Any) -> None: | ||
# Performance is really bad for list config iteration, not sure why. |
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.
Why is that surprising? If you compare to a regular list, ListConfig is doing a lot more stuff to check if any interpolation needs to be resolved, while a regular list can instantly return the reference to the object.
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.
Because it's 500 times slower :).
I don't think it's justified. I tried to profile it a bit and do some blind optimizations but was not able to pinpoint the cause.
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.
Ok -- actually given the speed-up that you got here, I do agree that it should be possible to iterate faster (x in lst
shouldn't be much faster than for y in lst
-- at least when iterating through the whole list in both cases)
Speedup from 1200x slower than standard list contains to only 68 times slower :)
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.
Looks good!
Speedup from 1200x slower than standard list contains to only 68 times slower (~15x).
Closes #529