summaryrefslogtreecommitdiffstats
path: root/Python/specialize.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/specialize.c')
-rw-r--r--Python/specialize.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Python/specialize.c b/Python/specialize.c
index 70a456c..5717991 100644
--- a/Python/specialize.c
+++ b/Python/specialize.c
@@ -2184,7 +2184,7 @@ int
#endif
void
-_Py_Specialize_ForIter(PyObject *iter, _Py_CODEUNIT *instr)
+_Py_Specialize_ForIter(PyObject *iter, _Py_CODEUNIT *instr, int oparg)
{
assert(_PyOpcode_Caches[FOR_ITER] == INLINE_CACHE_ENTRIES_FOR_ITER);
_PyForIterCache *cache = (_PyForIterCache *)(instr + 1);
@@ -2199,6 +2199,11 @@ _Py_Specialize_ForIter(PyObject *iter, _Py_CODEUNIT *instr)
_Py_SET_OPCODE(*instr, FOR_ITER_RANGE);
goto success;
}
+ else if (tp == &PyGen_Type && oparg <= SHRT_MAX) {
+ assert(_Py_OPCODE(instr[oparg + INLINE_CACHE_ENTRIES_FOR_ITER + 1]) == END_FOR);
+ _Py_SET_OPCODE(*instr, FOR_ITER_GEN);
+ goto success;
+ }
SPECIALIZATION_FAIL(FOR_ITER,
_PySpecialization_ClassifyIterator(iter));
STAT_INC(FOR_ITER, failure);