Skip to content

Commit 7c890ed

Browse files
committed
GH-98363: Slicing isn't necessary. A resize will suffice.
1 parent 8d57423 commit 7c890ed

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Modules/itertoolsmodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ batched_next(batchedobject *bo)
181181
Py_DECREF(result);
182182
return NULL;
183183
}
184-
PyObject *short_list = PyList_GetSlice(result, 0, i);
185-
Py_DECREF(result);
186-
return short_list;
184+
/* Elements in result[i:] are still NULL */
185+
Py_SET_SIZE(result, i);
186+
return result;
187187
}
188188

189189
static PyTypeObject batched_type = {

0 commit comments

Comments
 (0)