mirror of
https://github.com/python/cpython.git
synced 2025-11-12 23:16:47 +00:00
Issue #24276: Fixed optimization of property descriptor getter.
This commit is contained in:
parent
3805019c58
commit
a7a0ad6f73
2 changed files with 23 additions and 4 deletions
|
|
@ -10,6 +10,8 @@ Release date: 2015-05-24
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #24276: Fixed optimization of property descriptor getter.
|
||||||
|
|
||||||
- Issue #24268: PEP 489: Multi-phase extension module initialization
|
- Issue #24268: PEP 489: Multi-phase extension module initialization
|
||||||
|
|
||||||
- Issue #23955: Add pyvenv.cfg option to suppress registry/environment
|
- Issue #23955: Add pyvenv.cfg option to suppress registry/environment
|
||||||
|
|
|
||||||
|
|
@ -1372,7 +1372,8 @@ property_dealloc(PyObject *self)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
property_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
property_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
||||||
{
|
{
|
||||||
static PyObject *args = NULL;
|
static PyObject * volatile cached_args = NULL;
|
||||||
|
PyObject *args;
|
||||||
PyObject *ret;
|
PyObject *ret;
|
||||||
propertyobject *gs = (propertyobject *)self;
|
propertyobject *gs = (propertyobject *)self;
|
||||||
|
|
||||||
|
|
@ -1384,12 +1385,28 @@ property_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
||||||
PyErr_SetString(PyExc_AttributeError, "unreadable attribute");
|
PyErr_SetString(PyExc_AttributeError, "unreadable attribute");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!args && !(args = PyTuple_New(1))) {
|
args = cached_args;
|
||||||
return NULL;
|
if (!args || Py_REFCNT(args) != 1) {
|
||||||
|
Py_CLEAR(cached_args);
|
||||||
|
if (!(cached_args = args = PyTuple_New(1)))
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Py_INCREF(args);
|
||||||
|
assert (Py_REFCNT(args) == 2);
|
||||||
|
Py_INCREF(obj);
|
||||||
PyTuple_SET_ITEM(args, 0, obj);
|
PyTuple_SET_ITEM(args, 0, obj);
|
||||||
ret = PyObject_Call(gs->prop_get, args, NULL);
|
ret = PyObject_Call(gs->prop_get, args, NULL);
|
||||||
PyTuple_SET_ITEM(args, 0, NULL);
|
if (args == cached_args) {
|
||||||
|
if (Py_REFCNT(args) == 2) {
|
||||||
|
obj = PyTuple_GET_ITEM(args, 0);
|
||||||
|
PyTuple_SET_ITEM(args, 0, NULL);
|
||||||
|
Py_XDECREF(obj);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Py_CLEAR(cached_args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Py_DECREF(args);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue