mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
GH-100110: Specialize FOR_ITER for tuples (GH-100109)
* Specialize FOR_ITER for tuples
This commit is contained in:
parent
0448deac70
commit
748c6c0921
10 changed files with 122 additions and 67 deletions
23
Python/generated_cases.c.h
generated
23
Python/generated_cases.c.h
generated
|
@ -2759,6 +2759,29 @@
|
|||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(FOR_ITER_TUPLE) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
_PyTupleIterObject *it = (_PyTupleIterObject *)TOP();
|
||||
DEOPT_IF(Py_TYPE(it) != &PyTupleIter_Type, FOR_ITER);
|
||||
STAT_INC(FOR_ITER, hit);
|
||||
PyTupleObject *seq = it->it_seq;
|
||||
if (seq) {
|
||||
if (it->it_index < PyTuple_GET_SIZE(seq)) {
|
||||
PyObject *next = PyTuple_GET_ITEM(seq, it->it_index++);
|
||||
PUSH(Py_NewRef(next));
|
||||
JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER);
|
||||
goto end_for_iter_tuple; // End of this instruction
|
||||
}
|
||||
it->it_seq = NULL;
|
||||
Py_DECREF(seq);
|
||||
}
|
||||
STACK_SHRINK(1);
|
||||
Py_DECREF(it);
|
||||
JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1);
|
||||
end_for_iter_tuple:
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(FOR_ITER_RANGE) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
_PyRangeIterObject *r = (_PyRangeIterObject *)TOP();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue