python速度快吗_Python的速度有多快?

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, 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 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: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.

Spend a few tens of millions on developing just-in-time compilers

and program analysis. That worked for Java.

Nothing is written in assembly, except that C can be considered

a portable assembly language. Otherwise ports to different platforms

would be a lot more difficult.

I would hope that the C compiler could optimize the C code

sufficiently well for the hardware, rather than tweaking the

code by hand. (Though I know of at least one person who sent

in a patch to gcc to optimize poorly written in-house code.

Rather circuitous way to fix things, but it worked.)

Andrew

da***@dalkescientific.com

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值