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

@ -443,7 +443,6 @@ float_richcompare(PyObject *v, PyObject *w, int op)
double fracpart;
double intpart;
PyObject *result = NULL;
PyObject *one = NULL;
PyObject *vv = NULL;
PyObject *ww = w;
@ -466,23 +465,19 @@ float_richcompare(PyObject *v, PyObject *w, int op)
*/
PyObject *temp;
one = PyLong_FromLong(1);
if (one == NULL)
goto Error;
temp = PyNumber_Lshift(ww, one);
temp = PyNumber_Lshift(ww, _PyLong_One);
if (temp == NULL)
goto Error;
Py_DECREF(ww);
ww = temp;
temp = PyNumber_Lshift(vv, one);
temp = PyNumber_Lshift(vv, _PyLong_One);
if (temp == NULL)
goto Error;
Py_DECREF(vv);
vv = temp;
temp = PyNumber_Or(vv, one);
temp = PyNumber_Or(vv, _PyLong_One);
if (temp == NULL)
goto Error;
Py_DECREF(vv);
@ -496,7 +491,6 @@ float_richcompare(PyObject *v, PyObject *w, int op)
Error:
Py_XDECREF(vv);
Py_XDECREF(ww);
Py_XDECREF(one);
return result;
}
} /* else if (PyLong_Check(w)) */
@ -1617,7 +1611,7 @@ float_subtype_new(PyTypeObject *type, PyObject *x);
/*[clinic input]
@classmethod
float.__new__ as float_new
x: object(c_default="Py_False") = 0
x: object(c_default="_PyLong_Zero") = 0
/
Convert a string or number to a floating point number, if possible.