GH-100110: Specialize FOR_ITER for tuples (GH-100109)

* Specialize FOR_ITER for tuples
This commit is contained in:
Ken Jin 2022-12-09 18:27:01 +08:00 committed by GitHub
parent 0448deac70
commit 748c6c0921
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 122 additions and 67 deletions

View file

@ -2132,6 +2132,10 @@ _Py_Specialize_ForIter(PyObject *iter, _Py_CODEUNIT *instr, int oparg)
_Py_SET_OPCODE(*instr, FOR_ITER_LIST);
goto success;
}
else if (tp == &PyTupleIter_Type) {
_Py_SET_OPCODE(*instr, FOR_ITER_TUPLE);
goto success;
}
else if (tp == &PyRangeIter_Type && next_op == STORE_FAST) {
_Py_SET_OPCODE(*instr, FOR_ITER_RANGE);
goto success;