mirror of
https://github.com/python/cpython.git
synced 2025-10-17 04:08:28 +00:00
bpo-29878: Add global instances of int for 0 and 1. (#852)
This commit is contained in:
parent
e6911a44f6
commit
ba85d69a3e
18 changed files with 105 additions and 249 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue