From: Daniel Carrera Date: 2004-01-13T00:38:46+09:00 Subject: Re: faster integer arithmetics & arbitrary precision floating number > >$ time perl -e'for(1..1000000){1073741823+1073741824}' > > > >real 0m1.142s > >user 0m0.320s > >sys 0m0.050s > > > >since 2**30 is already in the Bignum range. > > i have the feeling (unconfirmed) that perl is optimising it away since > the result is unused or the operation repeated or something. i created a > file with 1000000 lines repeating the addition and perl is very slow too > then (and ruby too). That seems likely. Which brings up another point, shouldn't ruby have such an optimization also? Yes, I know that you can redefine the Integer class so that + does something weird, which means that you don't know what each + does until you are actually there. But suppose that there were a Ruby flag where I "promise" I haven't done anything odd to the numeric classes, and it is safe to optimize them. Wouldn't that be a good idea? -- Daniel Carrera | No trees were harmed in the generation of this e-mail. PhD student. | A significant number of electrons were, however, severely Math Dept. UMD | inconvenienced.