From: ptkwt@... (Phil Tomson) Date: 2004-11-06T08:13:41+09:00 Subject: Re: Ruby is a slow performer In article <20041105220018.GA5484@miya.intranet.ntecs.de>, Michael Neumann wrote: >On Sat, Nov 06, 2004 at 06:31:33AM +0900, David G. Andersen wrote: >> On Sat, Nov 06, 2004 at 06:23:41AM +0900, Christian Szegedy scribed: >> > gabriele renzi wrote: >> > >> > >About the shootout. Most of the stuff is plan useless in ruby. >> > >You won't implemente heapsort in ruby, cause you have sort/sort_by. >> > >Nor you would use >> > >http://shootout.alioth.debian.org/lang/ruby/random.ruby.html >> > >because you have rand(). >> > >> > You are correct. I would say that the shootout is extremely >> > misleading, for example the Python people do dubious tricks >> > to make it look fast: for example the matrix multiplication is >> > implemented by calling the an extension method. >> >> Why is that unrealistic? You could do the same in Ruby by >> implementing the library 'Matrix' class in C. We already have >> a library that handles the stuff; it's just a matter of >> optimization (== time == extra code in C that's harder to >> maintain, unfortunately). I actually played with this a bit. >> Right now, using the Ruby matrix class does two things to >> that test: >> >> a) Reduces the lines of code by nearly half >> b) Increases the runtime by a factor of two. (ouch) >> >> If we had a superfast matrix class, it would give (a) along >> with decreasing the runtime by a factor of ten or so. Sounds > >We have a superfast matrix class: NArray (not in standard lib). >It claimed to be 3x faster than NumPy for some tests and a bit faster >than Octave for for matrix operations. > >http://www.ir.isas.ac.jp/~masa/ruby/index-e.html > Is the Python extension in question part of Python's standard lib? If so, I could see how using it in the shootout would be OK. Perhaps it's time to nominate NArray for inclusion in Ruby's standard lib. Given that matrix operations are one of the more compute intensive tasks it might be a good idea. ....Also, I wonder if NArray might be in need of renaming. maybe something like FastArray/FastMatrix/FastVector - that would make the purpose perhaps a bit clearer. I find that I always forget about NArray when I need a fast matrix (which isn't often, but sometimes). Phil