Visitar URL original
gh-89189: More compact range iterator by serhiy-storchaka · Pull Request #27986 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Microoptimize small range iteration.
  • Loading branch information
serhiy-storchaka committed Nov 27, 2022
commit 10822c03ddf124c7e99f820366531d7344713bcc
2 changes: 1 addition & 1 deletion Objects/rangeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ rangeiter_next(_PyRangeIterObject *r)
{
if (r->len > 0) {
long result = r->start;
r->start += r->step;
r->start = result + r->step;
r->len--;
return PyLong_FromLong(result);
}
Expand Down
2 changes: 1 addition & 1 deletion Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2627,7 +2627,7 @@ dummy_func(
}
else {
long value = r->start;
r->start += r->step;
r->start = value + r->step;
r->len--;
if (_PyLong_AssignValue(&GETLOCAL(_Py_OPARG(next)), value) < 0) {
goto error;
Expand Down
2 changes: 1 addition & 1 deletion Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.