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

@ -529,15 +529,8 @@ keyobject_richcompare(PyObject *ko, PyObject *other, int op)
PyObject *y;
PyObject *compare;
PyObject *answer;
static PyObject *zero;
PyObject* stack[2];
if (zero == NULL) {
zero = PyLong_FromLong(0);
if (!zero)
return NULL;
}
if (Py_TYPE(other) != &keyobject_type){
PyErr_Format(PyExc_TypeError, "other argument must be K instance");
return NULL;
@ -561,7 +554,7 @@ keyobject_richcompare(PyObject *ko, PyObject *other, int op)
return NULL;
}
answer = PyObject_RichCompare(res, zero, op);
answer = PyObject_RichCompare(res, _PyLong_Zero, op);
Py_DECREF(res);
return answer;
}