Skip to content
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

Faster dict iteration #167

Closed
JukkaL opened this issue Jun 26, 2018 · 1 comment · Fixed by python/mypy#8725
Closed

Faster dict iteration #167

JukkaL opened this issue Jun 26, 2018 · 1 comment · Fixed by python/mypy#8725

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Jun 26, 2018

Using PyDict_Next would likely be a faster way to iterate over dictionaries. Implementing this in the IR seems a little tricky, since the API call mutates multiple registers, whereas primitive ops are expected to only mutate a single register. Returning a tuple internally might be a reasonable way to support this.

For more information, see https://docs.python.org/3/c-api/dict.html#c.PyDict_Next.

@msullivan
Copy link
Collaborator

We now use the "return a tuple internally" strategy for dealing with exc_info tuples in the exception APIs and it works well, so that is probably the way forward for this.

@r3m0t r3m0t mentioned this issue Apr 1, 2020
15 tasks
ilevkivskyi added a commit to python/mypy that referenced this issue May 6, 2020
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%

Note: we don't apply the fast path to subclasses here to make dict subclassing safe.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants