Chris Angelico added the comment: The trouble with that example is that the semantics aren't the same. The isinstance check will also be true for subclasses of int (for instance, isinstance(True,int) is True), but the equality check will catch only exact matches. And that's even before considering that anything can be overridden - the name 'type' or 'int' might have been rebound, or the type object might have an __eq__ method, etc, etc.
If you want to look into CPython optimization, hang out on the python-dev mailing list (and read its recent archives); there's a current project called "FAT Python" which does a lot of changes of this nature, and it has to cope with certain questions (like "what if this has been rebound?"). This isn't a simple problem, but it's one people are looking into. ---------- nosy: +Rosuav _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25903> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com