mirror of
https://github.com/python/cpython.git
synced 2025-09-15 05:06:12 +00:00
bpo-45510: Specialize BINARY_SUBTRACT (GH-29523)
This commit is contained in:
parent
0920b61a0c
commit
345ba3f080
7 changed files with 107 additions and 50 deletions
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue