[issue1762] Inheriting from ABC slows Decimal down.

Christian Heimes report at bugs.python.org
Tue Jan 8 19:03:20 CET 2008


Christian Heimes added the comment:

without abc:
$ time ./python Lib/test/regrtest.py test_decimal
real    0m10.113s
user    0m9.685s
sys     0m0.196s

with numbers.Real subclass:
$ time ./python Lib/test/regrtest.py  test_decimal
real    0m16.232s
user    0m15.241s
sys     0m0.384s

Proposed patch:
$ time ./python Lib/test/regrtest.py  test_decimal
real    0m11.128s
user    0m9.533s
sys     0m0.260s

Only with if instance.__class__ in cls._abc_cache: return True
$ time ./python Lib/test/regrtest.py  test_decimal
real    0m11.201s
user    0m10.345s
sys     0m0.292s

Wow, __instancecheck__ must be called a *lot* of times.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1762>
__________________________________


More information about the Python-bugs-list mailing list