On Sun, Dec 30, 2001 at 11:08:33AM +0900, Tomasz Wegrzanowski wrote:
> Does such thing already exist ?

I made such thing during learning how to extend Ruby, but it's quite useful.
It's available at http://freebsd.orzeszkowej.ble.pl/~taw/ruby_gmp.alpha1.tar.bz2
It contains support only for infinite precision integers and rationals, not floats.
It is unfinished and probably contains some bugs.
It contains test suite of 9 short tests, and 8 of them it passes.
One not passed is due to not implemented feature, not a bug.

Ruby-GMP significantly beats Ruby BigNum in performance.
Here are results of  benchmarks run three times on my box (Athlon 1GHz, Debian GNU/Linux).
Benchmarks are in archive, here are BigNum versions only, so you can see
what is benchmarked.

Benchmark 1:
	a=1000
	b=1000
	(1..12).each { |i|
	    a*=b
	    b*=a
	}

Results of Ruby BigNum

       real       user         sys
    0m13.220s   0m13.200s    0m0.020s
    0m13.222s   0m13.210s    0m0.000s
    0m13.219s   0m13.210s    0m0.000s

Results of Ruby-GMP

    0m0.297s    0m0.300s     0m0.000s
    0m0.298s    0m0.290s     0m0.000s
    0m0.298s    0m0.290s     0m0.000s

Ruby-GMP is 45.0 times faster in user-time

Benchmark 2:
	a=1234
	b=5678
	(1..100000).each { |i|
	    a+=b
	    b+=a
	}

Results of Ruby BigNum
    0m18.990s	0m18.950s    0m0.040s
    0m18.981s	0m18.970s    0m0.010s
    0m18.967s   0m18.970s    0m0.000s

Results of Ruby-GMP - with copying objects
    0m9.692s    0m9.490s     0m0.110s
    0m9.620s    0m9.410s     0m0.210s
    0m9.637s    0m9.490s     0m0.140s

Results of Ruby-GMP - with modifying objects
    0m1.344s    0m1.340s     0m0.010s
    0m1.346s    0m1.340s     0m0.010s
    0m1.348s    0m1.340s     0m0.000s

Ruby-GMP is 2.0 times faster using copying and 14.15 times faster using modifying.

GMP page says that its resuts on Athlon are significantly better than on other
i86 processors, so gaps might be smaller in your tests.