comparison Python/errors.c @ 48876:d01c1d768841 legacy-trunk

Issue #2534: speed up isinstance() and issubclass() by 50-70%, so as to match Python 2.5 speed despite the __instancecheck__ / __subclasscheck__ mechanism. In the process, fix a bug where isinstance() and issubclass(), when given a tuple of classes as second argument, were looking up __instancecheck__ / __subclasscheck__ on the tuple rather than on each type object. Reviewed by Benjamin Peterson and Raymond Hettinger.
author Antoine Pitrou <solipsis@pitrou.net>
date Tue, 26 Aug 2008 22:42:08 +0000
parents 0fbddc04aee1
children 3889d9528601 7e86fa255fc2
comparison
equal deleted inserted replaced
48872:edd2ca894a67 48876:d01c1d768841
111 PyErr_Fetch(&exception, &value, &tb); 111 PyErr_Fetch(&exception, &value, &tb);
112 res = PyObject_IsSubclass(err, exc); 112 res = PyObject_IsSubclass(err, exc);
113 /* This function must not fail, so print the error here */ 113 /* This function must not fail, so print the error here */
114 if (res == -1) { 114 if (res == -1) {
115 PyErr_WriteUnraisable(err); 115 PyErr_WriteUnraisable(err);
116 /* issubclass did not succeed */
117 res = 0; 116 res = 0;
118 } 117 }
119 PyErr_Restore(exception, value, tb); 118 PyErr_Restore(exception, value, tb);
120 return res; 119 return res;
121 } 120 }