mirror of
https://github.com/python/cpython.git
synced 2025-08-25 03:04:55 +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
|
@ -2523,6 +2523,29 @@ dummy_func(
|
|||
end_for_iter_list:
|
||||
}
|
||||
|
||||
// stack effect: ( -- __0)
|
||||
inst(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:
|
||||
}
|
||||
|
||||
// stack effect: ( -- __0)
|
||||
inst(FOR_ITER_RANGE) {
|
||||
assert(cframe.use_tracing == 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue