summaryrefslogtreecommitdiff
path: root/Objects/descrobject.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2015-04-30 08:08:13 -0700
committerRaymond Hettinger <python@rcn.com>2015-04-30 08:08:13 -0700
commitc4e335b67a5469e621fa4771454be99cc5aae791 (patch)
tree39c01d175ab987a00f979263098c7696e021821d /Objects/descrobject.c
parentdd2693fc1f157ff294ae57432bed4860d0fb491b (diff)
downloadcpython-git-c4e335b67a5469e621fa4771454be99cc5aae791.tar.gz
Issue #23910: Optimize property() getter calls. Patch by Joe Jevnik
Diffstat (limited to 'Objects/descrobject.c')
-rw-r--r--Objects/descrobject.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index 2df5ac5f73..822fb4182b 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -1372,6 +1372,8 @@ property_dealloc(PyObject *self)
static PyObject *
property_descr_get(PyObject *self, PyObject *obj, PyObject *type)
{
+ static PyObject *args = NULL;
+ PyObject *ret;
propertyobject *gs = (propertyobject *)self;
if (obj == NULL || obj == Py_None) {
@@ -1382,7 +1384,13 @@ property_descr_get(PyObject *self, PyObject *obj, PyObject *type)
PyErr_SetString(PyExc_AttributeError, "unreadable attribute");
return NULL;
}
- return PyObject_CallFunctionObjArgs(gs->prop_get, obj, NULL);
+ if (!args && !(args = PyTuple_New(1))) {
+ return NULL;
+ }
+ PyTuple_SET_ITEM(args, 0, obj);
+ ret = PyObject_Call(gs->prop_get, args, NULL);
+ PyTuple_SET_ITEM(args, 0, NULL);
+ return ret;
}
static int