diff -r b15c5a66213f Objects/abstract.c --- a/Objects/abstract.c Thu Oct 02 12:39:02 2014 +0200 +++ b/Objects/abstract.c Thu Oct 02 13:28:41 2014 +0200 @@ -2557,6 +2557,11 @@ PyObject_IsInstance(PyObject *inst, PyOb return r; } + if (Py_TYPE(cls) == &PyType_Type) { + /* We know what type's __instancecheck__ does. */ + return recursive_isinstance(inst, cls); + } + checker = _PyObject_LookupSpecial(cls, &PyId___instancecheck__); if (checker != NULL) { PyObject *res; @@ -2576,6 +2581,7 @@ PyObject_IsInstance(PyObject *inst, PyOb } else if (PyErr_Occurred()) return -1; + /* Probably never reached anymore. */ return recursive_isinstance(inst, cls); } @@ -2622,6 +2628,11 @@ PyObject_IsSubclass(PyObject *derived, P return r; } + if (Py_TYPE(cls) == &PyType_Type) { + /* We know what type's __subclasscheck__ does. */ + return recursive_issubclass(derived, cls); + } + checker = _PyObject_LookupSpecial(cls, &PyId___subclasscheck__); if (checker != NULL) { PyObject *res; @@ -2641,6 +2652,7 @@ PyObject_IsSubclass(PyObject *derived, P } else if (PyErr_Occurred()) return -1; + /* Probably never reached anymore. */ return recursive_issubclass(derived, cls); }