Author pitrou
Recipients ajaksu2, benjamin.peterson, djc, facundobatista, gregory.p.smith, pitrou, theller
Date 2008-08-25.21:11:21
SpamBayes Score 3.53835e-08
Marked as misclassified No
Message-id <1219698688.07.0.616886557.issue2534@psf.upfronthosting.co.za>
In-reply-to
Content
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%
History
Date User Action Args
2008-08-25 21:11:28pitrousetrecipients: + pitrou, theller, facundobatista, gregory.p.smith, ajaksu2, benjamin.peterson, djc
2008-08-25 21:11:28pitrousetmessageid: <1219698688.07.0.616886557.issue2534@psf.upfronthosting.co.za>
2008-08-25 21:11:27pitroulinkissue2534 messages
2008-08-25 21:11:26pitroucreate