diff options
author | Mark Shannon <mark@hotpy.org> | 2022-10-27 03:55:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-27 11:55:03 +0100 |
commit | 22863df7ca5f9cd01a40ab3dce3d067ec5666081 (patch) | |
tree | 73c460d80f41b45a331b7d886defe39127e12472 /Python/specialize.c | |
parent | e60892f9db1316dbabf7a652d7648e4f968b745d (diff) | |
download | cpython-git-22863df7ca5f9cd01a40ab3dce3d067ec5666081.tar.gz |
GH-96793: Change `FOR_ITER` to not pop the iterator on exhaustion. (GH-96801)
Change FOR_ITER to have the same stack effect regardless of whether it branches or not.
Performance is unchanged as FOR_ITER (and specialized forms jump over the cleanup code).
Diffstat (limited to 'Python/specialize.c')
-rw-r--r-- | Python/specialize.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/Python/specialize.c b/Python/specialize.c index b7c321e487..6e2fa4e25f 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -2208,12 +2208,8 @@ _Py_Specialize_ForIter(PyObject *iter, _Py_CODEUNIT *instr) _Py_SET_OPCODE(*instr, FOR_ITER_RANGE); goto success; } - else { - SPECIALIZATION_FAIL(FOR_ITER, - _PySpecialization_ClassifyIterator(iter)); - goto failure; - } -failure: + SPECIALIZATION_FAIL(FOR_ITER, + _PySpecialization_ClassifyIterator(iter)); STAT_INC(FOR_ITER, failure); cache->counter = adaptive_counter_backoff(cache->counter); return; |