bpo-45510: Specialize BINARY_SUBTRACT (GH-29523)

This commit is contained in:
Dong-hee Na 2021-11-18 18:19:58 +09:00 committed by GitHub
parent 0920b61a0c
commit 345ba3f080
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 107 additions and 50 deletions

View file

@ -3155,14 +3155,11 @@ long_add(PyLongObject *a, PyLongObject *b)
return _PyLong_Add(a, b);
}
static PyObject *
long_sub(PyLongObject *a, PyLongObject *b)
PyObject *
_PyLong_Subtract(PyLongObject *a, PyLongObject *b)
{
PyLongObject *z;
CHECK_BINOP(a, b);
if (IS_MEDIUM_VALUE(a) && IS_MEDIUM_VALUE(b)) {
return _PyLong_FromSTwoDigits(medium_value(a) - medium_value(b));
}
@ -3187,6 +3184,13 @@ long_sub(PyLongObject *a, PyLongObject *b)
return (PyObject *)z;
}
static PyObject *
long_sub(PyLongObject *a, PyLongObject *b)
{
CHECK_BINOP(a, b);
return _PyLong_Subtract(a, b);
}
/* Grade school multiplication, ignoring the signs.
* Returns the absolute value of the product, or NULL if error.
*/