mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
GH-102300: Reuse objects with refcount == 1 in float specialized binary ops. (GH-102301)
This commit is contained in:
parent
78e4e6c3d7
commit
233e32f936
4 changed files with 27 additions and 24 deletions
|
@ -350,3 +350,23 @@ GETITEM(PyObject *v, Py_ssize_t i) {
|
|||
|
||||
#define KWNAMES_LEN() \
|
||||
(kwnames == NULL ? 0 : ((int)PyTuple_GET_SIZE(kwnames)))
|
||||
|
||||
#define DECREF_INPUTS_AND_REUSE_FLOAT(left, right, dval, result) \
|
||||
do { \
|
||||
if (Py_REFCNT(left) == 1) { \
|
||||
((PyFloatObject *)left)->ob_fval = (dval); \
|
||||
_Py_DECREF_SPECIALIZED(right, _PyFloat_ExactDealloc);\
|
||||
result = (left); \
|
||||
} \
|
||||
else if (Py_REFCNT(right) == 1) {\
|
||||
((PyFloatObject *)right)->ob_fval = (dval); \
|
||||
_Py_DECREF_NO_DEALLOC(left); \
|
||||
result = (right); \
|
||||
}\
|
||||
else { \
|
||||
result = PyFloat_FromDouble(dval); \
|
||||
if ((result) == NULL) goto error; \
|
||||
_Py_DECREF_NO_DEALLOC(left); \
|
||||
_Py_DECREF_NO_DEALLOC(right); \
|
||||
} \
|
||||
} while (0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue