From: Mathieu Bouchard Date: 2005-10-27T15:08:09+09:00 Subject: Re: Time for built-in Rational and Complex classes? On Thu, 27 Oct 2005, Charles Mills wrote: > I don't see why not. But using GCD as an example the C version would > have to handle fixnums, bignums and arbitrary types that respond to > +,-,*,/,etc. You could just do a straight translation into C using > rb_funcall(), but if you wanted to see a speed up for the common case > (fixnum and bignum) than it would require handling those cases specially > (using arithmetic in C and the rb_big_*() functions). > Is there a more straight forward solution? The case of gcd and Rational is different from the case of Complex in that I'm not too sure Rationals make sense with anything non-integer. Anyone tried using the current Rational class with some kind of Polynomial class? did it work, or did it break some assumptions of Rational? A first step would be to make gcd a method in Integer (or in both Fixnum and Bignum) and make it use #coerce. I can provide some C implementations of gcd for Fixnums. But first, is there anyone who has profiled Rational and can tell that gcd really is a major time consumer ? What do commonly used denominators look like and how do they affect the speed of gcd ? ____________________________________________________________________ Mathieu Bouchard - t�l:+1.514.383.3801 - http://artengine.ca/matju Freelance Digital Arts Engineer, Montr�al QC Canada