Stefan Behnel added the comment: Here is another little optimisation that removes the redundant property lookups for the denominator in __add__() and __sub__().
New profile: 5291182 function calls (5290800 primitive calls) in 3.596 seconds Ordered by: internal time ncalls tottime percall cumtime percall filename:lineno(function) 519632 0.843 0.000 0.843 0.000 fractions.py:17(gcd) 519644 0.800 0.000 1.709 0.000 fractions.py:73(__new__) 319744 0.520 0.000 1.816 0.000 fractions.py:408(_add) 4 0.401 0.100 3.582 0.896 bm_telco_fractions.py:38(run) 519616 0.291 0.000 3.156 0.000 fractions.py:381(forward) 199872 0.274 0.000 0.904 0.000 fractions.py:424(_mul) 520257 0.145 0.000 0.145 0.000 {built-in method isinstance} 959232 0.108 0.000 0.108 0.000 fractions.py:285(denominator) 959232 0.108 0.000 0.108 0.000 fractions.py:281(numerator) 519657 0.066 0.000 0.066 0.000 {built-in method __new__ of type object at 0x9d1c40} ---------- Added file: http://bugs.python.org/file36691/avoid_redundant_property_lookups.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22464> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com