Antoine Pitrou <[EMAIL PROTECTED]> added the comment:
Ok, here is the patch for py3k. As I said it fixes some interesting bugs
(when the second argument was a tuple, isinstance() and issubclass()
were trying to get __instancecheck__ / __subclasscheck__ on the tuple
rather than on each of the tuple items). I also had to disable
__subclasscheck__ for exception matching, otherwise there are some nasty
issues with recursion checking.
The patch for trunk should probably be reworked or regenerated from the
py3k patch.
Performance numbers:
timeit -s "val=ValueError(); cls=EOFError" "isinstance(val, cls)"
- before patch: 1.63 usec per loop
- after patch: 0.683 usec per loop
timeit -s "val=ValueError(); cls=EOFError" "isinstance(val, (cls,))"
- before patch: 1.86 usec per loop
- after patch: 0.773 usec per loop
timeit -s "val=ValueError; cls=EOFError" "issubclass(val, cls)"
- before patch: 1.95 usec per loop
- after patch: 0.624 usec per loop
timeit -s "val=ValueError; cls=EOFError" "issubclass(val, (cls,))"
- before patch: 2.35 usec per loop
- after patch: 0.721 usec per loop
pybench
-------
("this" is with patch, "other" is without)
Test minimum run-time average run-time
this other diff this other
diff
-------------------------------------------------------------------------------
TryRaiseExcept: 77ms 136ms -43.5% 77ms 137ms
-43.5%
WithRaiseExcept: 189ms 280ms -32.6% 190ms 282ms
-32.6%
-------------------------------------------------------------------------------
Totals: 266ms 416ms -36.1% 267ms 419ms
-36.2%
Added file: http://bugs.python.org/file11256/isinstance3k.patch
_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2534>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com