为什么 ruby 1.9 比 python 2.7 和 3.2 更快?
我读了这堆链接: http://pack.li/L
ruby 1.9 似乎比1.8...并且比 python 2.7 和 3.2 更快
我做了一些测试,它不仅是在递归上(我知道 python 对此很糟糕),还提供了更多标准的东西。
我的问题是:Ruby 团队是如何做到这一点的? 2 倍改进 ? 它们是否包含 JIT 编译器/优化器之类的?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我是红宝石爱好者,我认为您没有完全阅读那些(相当旧的)文章。两人都承认使用了……“耸人听闻”的标题。而且他们使用的算法并不是最优的。所以它们在我眼里没有什么价值。
我所知道的比较语言的“最佳”地方是 http://benchmarksgame.alioth.debian.org/。我引用“最佳”是因为正如其他人所说,基于一堆特定实现的分段语言速度缺乏统计严谨性。
也就是说,如果您将 ruby 1.9 与 Python 3 进行对比,您会得到这些结果
结果是:在使用的 10 项测试中,Ruby 1.9 在 2 项测试中比 Python 更快。它在 4 中类似,而在其余部分中则较慢(最后一个示例太糟糕了,我很想称其为虚假)
因此,根据这 10 个不同的测试,我们只能得出这样的结论:不,Ruby 在以下方面并不比 Python 快一般的。 (仅在某些特定情况下)。
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).
所以你指出了一个博客,其中显示了一个算法的 2 个天真的实现,该算法本身很糟糕......然后作者比较了这两个人为的程序并决定整个“(运行时环境)烟熏(其他环境)”。
不仅这些基准测试不能证明任何东西(除了特定基准测试的执行速度之外),而且如果您实际上查看了实现,您可以找到一些在 python 中更优化的位,创建自己的基准测试,经常使用该位并“证明” ”相反的结果。
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.
除了 @egarcia 和 @viraptor 的评论之外,我想指出的是,这些基准测试比较的是 Ruby 和 CPython,特别是 Python 实现,而不是语言。有更快的 Python 实现,例如 PyPy。并且还有不同的 Ruby 实现。您无法比较“语言性能”,只能比较特定的实现。
有关快速 2.x python 的更多信息 - http://speed.pypy.org/
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/