[issue2303] isinstance is 4x as slow as in 2.5 because the common case raises
Gregory P. Smith
report at bugs.python.org
Sun Jul 13 20:38:28 CEST 2008
Gregory P. Smith <greg at krypto.org> added the comment:
% ./python.exe -mtimeit 'isinstance(3, int)'
1000000 loops, best of 3: 0.269 usec per loop
% ../release25-maint/python.exe -mtimeit 'isinstance(3, int)'1000000
loops, best of 3: 0.335 usec per loop
So I'd say its no longer 4x slower these days.
Looking at the Object/abstract.c it appears the fix to this has already
been checked in. PyObject_IsInstance already has this in it:
/* Quick test for an exact match */
if (Py_TYPE(inst) == (PyTypeObject *)cls)
return 1;
closing.
----------
nosy: +gregory.p.smith
resolution: -> accepted
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2303>
_______________________________________
More information about the Python-bugs-list
mailing list