[issue1682] Move Demo/classes/Rat.py to Lib/fractions.py and fix it up.
Mark Dickinson
report at bugs.python.org
Tue Feb 12 23:15:59 CET 2008
Mark Dickinson added the comment:
> BTW I think the next goal should be to reduce the cost of constructing
> a Fraction out of to plain ints by at least an order of magnitude. I
> believe this is possible.
I certainly hope so! Here's a very simple (and simplistic) benchmark:
# start benchmark
from fractions import Fraction
from cProfile import run
def test1():
return sum(Fraction(1, n*n-1) for n in xrange(2, 100000))
run("test1()")
#end benchmark
On my MacBook this reports a total time of 38.072 seconds, with 22.731 of
those (i.e. around 60%) being spent in abc.__instancecheck__ and its
callees.
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1682>
__________________________________
More information about the Python-bugs-list
mailing list