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
ChainMap.__contains__ and .get performance improvement. #118932
Comments
I'm curious: how long does |
621 ns |
The change to The |
Makes sense, can't think of any way to keep that and not to iterate twice. At least updating Should I issue PR or leave it to you? |
How much slower is this? https://stackoverflow.com/a/44803103 any(True for m in self.maps if key in m) |
Slightly faster than the original:
|
... but slower than an actual for loop. |
786 ns & 500 ns |
Looks like a complicated version of:
|
Which is the best I have seen without loop: |
Feature or enhancement
Proposal:
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
https://discuss.python.org/t/collections-chainmap-get-performance/41925
Linked PRs
The text was updated successfully, but these errors were encountered: