]> granicus.if.org Git - python/commitdiff
Speed-up isinstance() for one easy case.
authorRaymond Hettinger <python@rcn.com>
Tue, 18 Mar 2008 23:22:29 +0000 (23:22 +0000)
committerRaymond Hettinger <python@rcn.com>
Tue, 18 Mar 2008 23:22:29 +0000 (23:22 +0000)
Objects/abstract.c

index 0ea26d6e4b7fe23a908f8a6383f77c3cbb85f144..3315b0eb632d9c2bd7982d7dd2c1499c7e2d5ee6 100644 (file)
@@ -2909,6 +2909,11 @@ PyObject_IsInstance(PyObject *inst, PyObject *cls)
        static PyObject *name = NULL;
        PyObject *t, *v, *tb;
        PyObject *checker;
+
+       /* Quick test for an exact match */
+       if (Py_TYPE(inst) == cls)
+               return 1;
+
        PyErr_Fetch(&t, &v, &tb);
 
        if (name == NULL) {