mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
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.
This commit is contained in:
parent
f2f2a2c130
commit
c588e9041a
1 changed files with 1 additions and 1 deletions
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue