Skip to content

GH-132554: Add stats for GET_ITER #132592

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

Merged
merged 3 commits into from
Apr 29, 2025
Merged

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Apr 16, 2025

Before we can specialize GET_ITER, or even decide if it is worth specializing GET_ITER, we need stats.

@brandtbucher
Copy link
Member

I bet a lot of the "other" will already be iterators. It may be worth adding a stat at the end, before "other", for types where tp->tp_iter == PyObject_SelfIter. At least for that case we can specialize it and do nothing.

(I wish we could also "unwrap" list, tuple, and range iterators, similar in spirit to our method call optimization. Basically, if GET_ITER encounters a list_iterator, range_iterator, or tuple_iterator we just put the container itself and the current index on the stack. But that's not safe to do if its refcount is greater than one, unfortunately.)

@markshannon markshannon merged commit 622300b into python:main Apr 29, 2025
63 checks passed
@markshannon markshannon deleted the get-iter-stats branch April 29, 2025 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants