Python的速度有多快? [英] how fast is Python?

查看:82
本文介绍了Python的速度有多快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我爱这种语言是轻描淡写的。使用

现在整天带我花了3个小时,我可以把剩下的剩余时间花在我的自行车上,从高级别开始思考问题而不是

摔跤与晦涩的编译器问题等等。


当天回顾一种解释性语言(甚至是

)编译的)我要问的第一件事是,它的速度有多快?

这些天,1ghz处理器的机器卖得< 500美元,很少

出现问题。当然,在Py'的情况下,你总是可以扩展并嵌入你的核心例程以获得乐趣和优势。利润。


但是,肯定有很多代码需要优化的情况需要优化,所以我问的问题是:Python的速度有多快比较

说一个典型的优化C / C ++编译器?


我意识到这是一个比人们想象的更复杂的问题。

是各种类型的代码结构,可能最终会产生不同的b
效率问题。我想我要问的是,在一般意义上,

现在对于典型代码序列的速度有多快,而且 - 重要的是 -

可能是什么完成优化翻译?在装配中是否写了任何零件?b $ b?像哈希表这样的东西可以用并行的

单位(如MMX)进行优化吗?等等。


请指教。

It would be an understatement to say I love this language. What used
to take me all day now takes 3 hours, and I can spend the rest of the
time on my bike thinking about the problems from a high level instead
of wrestling with arcane compiler problems, etc.

Back in the day, when looking at an interpreted language (or even
compiled ones) the first thing I would ask is, "how fast is it?"
These days, with 1ghz processor machines selling for < $500, it seldom
comes up as an issue. And of course in Py''s case you can always
''extend and embed'' your core routines for fun & profit.

However, there are definitely cases where a lot of code would need to
be optimized, and so I ask the question: How fast is Python, compared
to say a typical optimizing C/C++ compiler?

I realize this is a more complex question than one might think. There
are various types of code constructs that might end up with different
efficiency issues. I guess what I''m asking is, in a general sense,
how fast is it now for typical code sequences, and -- importantly --
what could be done to optimize the interpreter? Are any parts written
in assembly? Could things like hash tables be optimized with parallel
units such as MMX? Etc.

Please advise.

推荐答案

500,它很少

出现问题。当然,在Py'的情况下,你总是可以扩展并嵌入你的核心例程以获得乐趣和优势。利润。


但是,肯定有很多代码需要优化的情况需要优化,所以我问的问题是:Python的速度有多快比较

说一个典型的优化C / C ++编译器?


我意识到这是一个比人们想象的更复杂的问题。

是各种类型的代码结构,可能最终会产生不同的b
效率问题。我想我要问的是,在一般意义上,

现在对于典型代码序列的速度有多快,而且 - 重要的是 -

可能是什么完成优化翻译?在装配中是否写了任何零件?b $ b?像哈希表这样的东西可以用并行的

单位(如MMX)进行优化吗?等等。
请指教。
500, it seldom
comes up as an issue. And of course in Py''s case you can always
''extend and embed'' your core routines for fun & profit.

However, there are definitely cases where a lot of code would need to
be optimized, and so I ask the question: How fast is Python, compared
to say a typical optimizing C/C++ compiler?

I realize this is a more complex question than one might think. There
are various types of code constructs that might end up with different
efficiency issues. I guess what I''m asking is, in a general sense,
how fast is it now for typical code sequences, and -- importantly --
what could be done to optimize the interpreter? Are any parts written
in assembly? Could things like hash tables be optimized with parallel
units such as MMX? Etc.

Please advise.


Python对我来说足够快,尤其是2.3。


简介&代码慢速部分作为C扩展。

如果需要,请在那里包括你自己的程序集。


调查Psyco。在这个

新闻组中有一个例子表明Python + psyco实际上

在编译的C中表现优于同一个程序。


--Irmen

Python is fast enough for me, especially 2.3.

Profile & code slow parts as C extensions.
Include your own assembly there if so desired.

Investigate Psyco. There was one example on this
newsgroup that showed that Python+psyco actually
outperformed the same program in compiled C.

--Irmen


dan:
但是,肯定有很多代码需要的情况
优化,所以我问一个问题:Python的速度有多快,比较典型的优化C / C ++编译器?


高度依赖于背景。我使用10-20因子作为球场,对于像低级别字符串处理这样的事情,使用系数为100的


例如,我有一个纯粹的Python regexp引擎的速度比sre慢了大约x80

。优化解释器可以做些什么?是否在装配中写了任何部件?像哈希表这样的东西可以用MMX这样的并行单元进行优化吗?等等。
However, there are definitely cases where a lot of code would need to
be optimized, and so I ask the question: How fast is Python, compared
to say a typical optimizing C/C++ compiler?
Highly dependent on context. I use factor of 10-20 as a ballpark,
with factor of 100 for some things like low-level string processing.
Eg, I''ve got a pure Python regexp engine which clocks at about x80
slower than sre.
what could be done to optimize the interpreter? Are any parts written
in assembly? Could things like hash tables be optimized with parallel
units such as MMX? Etc.




花费数千万美元开发即时编译器

和程序分析。这适用于Java。


除了可以认为C是可移植的汇编语言之外,没有任何内容可以用汇编语言编写。否则进入不同平台的端口

将会困难得多。


我希望C编译器可以优化C代码

足够好用于硬件,而不是手动调整

代码。 (虽然我知道至少有一个人在gcc的补丁中发送了

来优化写得不好的内部代码。

相当迂回的修复方法,但它工作。)


Andrew
da***@dalkescientific.com


这篇关于Python的速度有多快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆