Skip to content

Commit 0d33f29

Browse files
committed
macro(FOR_ITER_RANGE) = _ITER_CHECK_RANGE + _ITER_NEXT_RANGE + _FOR_ITER_END
1 parent a76a452 commit 0d33f29

File tree

4 files changed

+187
-161
lines changed

4 files changed

+187
-161
lines changed

Python/bytecodes.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -2500,9 +2500,15 @@ dummy_func(
25002500
// Common case: no jump, leave it to the code generator
25012501
}
25022502

2503-
op(_ITER_NEXT_RANGE, (iter -- iter, next)) {
2503+
op(_ITER_CHECK_RANGE, (iter -- iter)) {
25042504
_PyRangeIterObject *r = (_PyRangeIterObject *)iter;
25052505
DEOPT_IF(Py_TYPE(r) != &PyRangeIter_Type, FOR_ITER);
2506+
}
2507+
2508+
// NOTE: next may be NULL (TODO: Can we show this in the type?)
2509+
op(_ITER_NEXT_RANGE, (iter -- iter, next)) {
2510+
_PyRangeIterObject *r = (_PyRangeIterObject *)iter;
2511+
assert(Py_TYPE(r) == &PyRangeIter_Type);
25062512
STAT_INC(FOR_ITER, hit);
25072513
if (r->len <= 0) {
25082514
next = NULL;
@@ -2533,7 +2539,8 @@ dummy_func(
25332539
}
25342540
}
25352541

2536-
macro(FOR_ITER_RANGE) = unused/1 + _ITER_NEXT_RANGE + _FOR_ITER_END;
2542+
macro(FOR_ITER_RANGE) =
2543+
unused/1 + _ITER_CHECK_RANGE + _ITER_NEXT_RANGE + _FOR_ITER_END;
25372544

25382545
inst(FOR_ITER_GEN, (unused/1, iter -- iter, unused)) {
25392546
DEOPT_IF(tstate->interp->eval_frame, FOR_ITER);

Python/executor_cases.c.h

+40-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)