GH-145668: Add FOR_ITER specialization for virtual iterators. Specialize GET_ITER.#147967
GH-145668: Add FOR_ITER specialization for virtual iterators. Specialize GET_ITER.#147967markshannon wants to merge 20 commits intopython:mainfrom
Conversation
* Add FOR_ITER_VIRTUAL to specialize FOR_ITER for virtual iterators * Add GET_ITER_SELF to specialize GET_ITER for iterators (including generators) * Add GET_ITER_VIRTUAL to specialize GET_ITER for iterables as virtual iterators
|
Doesn't this change the ABI guarantees of |
|
|
…eption handling in genexpr
| _GUARD_ITER_VIRTUAL + | ||
| _PUSH_TAGGED_ZERO; | ||
|
|
||
| op(_GET_ITER_TRAD, (iterable -- iter, index_or_null)) { |
|
Do you have benchmark numbers for this? I'm wondering of 3 extra opcodes is worth it. I think I might have a solution for the opcode problem. |
In the noise. But this enables more optimizations, so neutral is good.
The By themselves, the two new
So the specializations follow naturally.
That's good, but not directly relevant to this PR I think. |
|
🤖 New build scheduled with the buildbot fleet by @Fidget-Spinner for commit a55ac63 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F147967%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
Add
FOR_ITERspecialization for virtual iterators. SpecializeGET_ITER.FOR_ITER_VIRTUALto specializeFOR_ITERfor virtual iteratorsGET_ITER_SELFto specializeGET_ITERfor iterators (including generators)GET_ITER_VIRTUALto specializeGET_ITERfor iterables as virtual iteratorstp_iteriteminternal slot toPyTypeObjectto support a wider range of classes as virtual iterators.This PR adds
strs as virtual iterators, with the potential to addbytes,bytearray,frozenset,frozendictand others in the future.FOR_ITERspecializations to cover other indexable sequences #145668📚 Documentation preview 📚: https://cpython-previews--147967.org.readthedocs.build/