开发者

Why ruby 1.9 is faster than python 2.7 and 3.2? [closed]

开发者 https://www.devze.com 2023-03-05 10:32 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago. 开发者_开发百科

I read this bunch of links : http://pack.li/L

ruby 1.9 seems to be 2 times faster than 1.8... and faster than python 2.7 and 3.2

I made some tests, it is not only on recursion (I knew python was bad about that), put for more standard stuff also.

So here is my question : How the ruby team have done that ? 2x improvement ? Do they include an JIT compiler/optimizer or something ?


I am a rubyist, and I think you didn't read those (quite old) articles fully. Both admit having used ... "sensationalist" headlines. And that the algorithms they use aren't optimal. So they have little value in my eyes.

The "best" place I know for comparing languages is http://benchmarksgame.alioth.debian.org/. I quote "best" because as others are saying, staging language speed based on a bunch of particular implementations lacks statistical rigor.

That said, if you pitch ruby 1.9 against Python 3, you get these results

The results are: of the 10 tests used, ruby 1.9 is faster than Python in 2 tests. It's similar in 4 and it's slower in the rest (the last example is so bad I'm tempted to call it spurious)

So, according to those 10 different tests, one can only conclude that no, ruby isn't faster than Python in general. (Only in some particular cases).


So you pointed at a blog which shows 2 naïve implementation of an algorithm which sucks itself... Then the author compares those two contrived programs and decides that the whole "(runtime environment) smokes (other environment) away".

Not only those benchmarks not prove anything (apart from speed of execution for that specific benchmark), but if you actually looked through the implementation you could find some bit that's more optimised in python, create own benchmark which uses that bit very often and "prove" the opposite result.


In addition to remarks of @egarcia and @viraptor, I'd like to note that these benchmarks compare Ruby and CPython, particular python implementation, rather than language. There are much faster python implementations around, like PyPy. And there are different Ruby implementations as well. You cannot compare 'language performance', only specific implementations.

For more info on fast 2.x python - http://speed.pypy.org/

0

精彩评论

暂无评论...
验证码 换一张
取 消