Extend `FOR_ITER` specializations to cover other indexable sequences
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Currently, we specialize FOR_ITER for both tuple and list. We also handle tuple and lists specially in GET_ITER to support this specialization.
We should extend this specialization of iteration over sequences, using virtual iterators to bytes, str, bytesarray and others.
To do this, we should:
- Add a
tp_getiteritemslots toPyTypeObjectfor sequences that can be efficiently indexed and cannot raise except for out-of-bounds access. - Add a specialization of
FOR_ITERfor these classes. - Specialize
GET_ITERfor:- iterators
- indexable sequences (those classes with a
tp_getiteritemslot)
- Specialize
SENDfor indexable sequences which should also improve JIT coverage, as unspecialized_SENDis currently a major cause of jit optimization failures.
Combined with https://github.com/python/cpython/issues/145667 this will allow effective specialization of a wider range of iterables and allow that specialization not only for for loops, but also for yield from loops.
It will add 3 instructions (4 new, 1 removed) which a reasonable
Linked PRs
- gh-145670
- gh-147967
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem Lesen der vorhandenen Spezialisierungen von FOR_ITER und GET_ITER und untersuche anschließend PyTypeObject und die SEND-Spezialisierung. Die Arbeit ist abgeschlossen, wenn indexierbare Sequenzen wie bytes und str in for-Schleifen und yield from-Schleifen virtuelle Iteratoren verwenden und die angeforderte Abdeckung der neuen Instruktionen vorhanden ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- compilers, performance
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 20/100