-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[mypyc] Faster dict iteration #8725
Conversation
Oh, tons of tests fail on Python 3.5 because this apparently changes dict iteration order there. It is probably a good opportunity to fix them (i.e. make them stable). |
@msullivan I think this should be now ready for review. Some notes:
|
FWIW, I believe that the most common uses of |
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.
Nice, this will speed up some very common operations. In a simple microbenchmark this made iteration about 30% faster. Left a few minor comments.
@msullivan So I disable the fast path for subclasses now (and enable on Python 3.5). It looks pretty complicated, but not too bad probably. Please let me know if it looks OK. |
This looks good to me. Let's merge this tomorrow unless @msullivan has some additional feedback. |
I am assuming Sully doesn't have any comments here, so will merge now. |
This covers both view and list versions (it looks like both are used relatively often, at least in mypy). This accompanies #8725 to account for cases where `keys`/`values`/`items` appear in non-loop contexts.
Fixes mypyc/mypyc#167
The implementation is pretty straightforward and follows the idea proposed in the issue. The perf impact is actually pretty small, around 1%