bpo-29878: Add global instances of int for 0 and 1. (#852)

This commit is contained in:
Serhiy Storchaka 2017-03-30 09:09:41 +03:00 committed by GitHub
parent e6911a44f6
commit ba85d69a3e
18 changed files with 105 additions and 249 deletions

View file

@ -374,9 +374,8 @@ _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
/* Convert step to an integer; raise for zero step. */
if (self->step == Py_None) {
step = PyLong_FromLong(1L);
if (step == NULL)
goto error;
step = _PyLong_One;
Py_INCREF(step);
step_is_negative = 0;
}
else {
@ -404,10 +403,8 @@ _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
goto error;
}
else {
lower = PyLong_FromLong(0L);
if (lower == NULL)
goto error;
lower = _PyLong_Zero;
Py_INCREF(lower);
upper = length;
Py_INCREF(upper);
}