On Jan 14, 10:43 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sun, 14 Jan 2007 15:32:35 -0800, dickinsm wrote: > > (You could include the normalization in __init__, but that's wasteful > Is it really? Have you measured it or are you guessing? Is it more or less > wasteful than any other solution?
Just guessing :). But when summing the reciprocals of the first 2000 positive integers, for example, with: sum((Rational(1, n) for n in range(1, 2001)), Rational(0)) the profile module tells me that the whole calculation takes 8.537 seconds, 8.142 of which are spent in my gcd() function. So it seemed sensible to eliminate unnecessary calls to gcd() when there's an easy way to do so. > def __copy__(self): > cls = self.__class__ > obj = cls.__new__(cls) > obj.numerator = self.numerator > obj.denominator = self.denominator > return obj Thank you for this. Mark -- http://mail.python.org/mailman/listinfo/python-list