summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-08-19 16:02:33 (GMT)
committerGuido van Rossum <guido@python.org>2002-08-19 16:02:33 (GMT)
commitc588e9041aea212fe2b5fad9254824d12f804c3e (patch)
tree751766986c00b71afdedcca0664f0890d08e62c9 /Objects
parentf2f2a2c130fc41bc854f376e13f4d6193a2b8b02 (diff)
downloadcpython-c588e9041aea212fe2b5fad9254824d12f804c3e.zip
cpython-c588e9041aea212fe2b5fad9254824d12f804c3e.tar.gz
cpython-c588e9041aea212fe2b5fad9254824d12f804c3e.tar.bz2
Simple but important optimization for descr_check(): instead of the
expensive and overly general PyObject_IsInstance(), call PyObject_TypeCheck() which is a macro that often avoids a call, and if it does make a call, calls the much more efficient PyType_IsSubtype(). This saved 6% on a benchmark for slot lookups.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/descrobject.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index cbf9e16..6daffc6 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -65,7 +65,7 @@ descr_check(PyDescrObject *descr, PyObject *obj, PyTypeObject *type,
*pres = (PyObject *)descr;
return 1;
}
- if (!PyObject_IsInstance(obj, (PyObject *)(descr->d_type))) {
+ if (!PyObject_TypeCheck(obj, descr->d_type)) {
PyErr_Format(PyExc_TypeError,
"descriptor '%s' for '%s' objects "
"doesn't apply to '%s' object",