蟒蛇的速度 [英] python speed

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

问题描述



Python的未来前景是否与java一样快?我想b $ b想用Python作为写游戏的语言。


最好的问候

krystian

Hi
are there any future perspectives for Python to be as fast as java? i
would like to use Python as a language for writing games.

best regards
krystian

推荐答案

文章< hh ****************************** **@4ax.com>,

Krystian< no **** @ this.home.com>写道:
In article <hh********************************@4ax.com>,
Krystian <no****@this.home.com> wrote:

Python的未来前景是否与java一样快?我希望使用Python作为编写游戏的语言。

are there any future perspectives for Python to be as fast as java? i
would like to use Python as a language for writing games.




为什么我们希望Python能够像Java一样快更快?


看看PyGame。

-

Aahz(aa**@pythoncraft.com)< * GT; http://www.pythoncraft.com/


在做出法律决定时,不要听USENET上的schmucks。雇用

你自己是一个称职的笨蛋。 --USENET schmuck(又名Robert Kern)



Why would we want Python to be as fast as Java when it''s already faster?

Take a look at PyGame.
--
Aahz (aa**@pythoncraft.com) <*> http://www.pythoncraft.com/

"Don''t listen to schmucks on USENET when making legal decisions. Hire
yourself a competent schmuck." --USENET schmuck (aka Robert Kern)


你好
还有未来的观点吗? Python的速度和java一样快?我希望使用Python作为编写游戏的语言。
为什么我们希望Python在Java已经更快的时候能够像Java一样快?
are there any future perspectives for Python to be as fast as java? i
would like to use Python as a language for writing games.
Why would we want Python to be as fast as Java when it''s already faster?




hm ...我遇到过这个网站:
http://shootout.alioth.debian.org/be...n&sort=fullcpu

你能对这个基准采取态度吗?

看看PyGame。



hm... i came across this site:
http://shootout.alioth.debian.org/be...n&sort=fullcpu

could you take an attitude with regard to this benchmark?
Take a look at PyGame.




在途中: )


最好

k



on my way :)

best
k


Krystian写道:
Krystian wrote:

Python的未来前景是否与java一样快?我希望使用Python作为编写游戏的语言。
为什么我们希望Python在Java已经更快的时候能够像Java一样快?
are there any future perspectives for Python to be as fast as java? i
would like to use Python as a language for writing games.
Why would we want Python to be as fast as Java when it''s already faster?



嗯...我遇到过这个网站:
http://shootout.alioth.debian.org/be...n&sort=fullcpu

你能带走吗?关于这个基准的态度?



hm... i came across this site:
http://shootout.alioth.debian.org/be...n&sort=fullcpu

could you take an attitude with regard to this benchmark?




基准没有价值。我的意思是他们对我没有任何价值

。重要的是在实际问题上的表现,例如产生第1代第6代[1,2] Mersenne Hailstone

Collat​​z序列。

这是一个很大的数字,需要大算术来解决。 Java有一个
a BigInteger模块,可以在不到10分钟的时间内解决它:


C:\Python23 \ user\pyjava> java Collat​​z 2 177149 1


处理时间:571690

x / 2次迭代:1531812

3x + 1次迭代:854697


参数计算结果为2 ** 177149-1。因为这是一个Mersenne数字,所以序列发散直到超过280000位

,然后在2386509次迭代后收敛到1位。


但对于如此困难的

问题,571秒是合理的时间吗?


将它与GMPY模块的Python进行比较:


C:\Python23 \ user\pyjava> collat​​z.py 2 177149 1

r1 1531812 r2 854697 in 72.9869999886秒


是的,看来在这个真实世界的应用程序中,Java是非常慢的。当然,Python正在使用GMPY进行繁重的工作,这是一个带有Python

包装器的编译C程序。但那又怎么样?也许我使用Python的原因是

因为数学模块是编译的C. Duh。使用Python / GMPY

我获得了算法所需的高级别功能,而没有

牺牲了重型算术所需的低级肌肉。



Benchmarks are worthless. By that I mean they have no value
to me. What matters is the performance on real problems, such
as generating the 1st 6th Generation Type [1,2] Mersenne Hailstone
Collatz sequence.

That''s a BIG number and needs BIG arithmetic to solve. Java has
a BigInteger module and can solve it in less than 10 minutes:

C:\Python23\user\pyjava>java Collatz 2 177149 1

Processing time: 571690
x/2 iterations: 1531812
3x+1 iterations: 854697

The arguments evaluate to 2**177149-1. And because this is a
Mersenne number, the sequence diverges until it''s over 280000 bits
before converging to 1 bit after 2386509 iterations.

But is 571 seconds a reasonable amount of time for such a difficult
problem?

Compare it to Python with the GMPY module:

C:\Python23\user\pyjava>collatz.py 2 177149 1
r1 1531812 r2 854697 in 72.9869999886 seconds

Yes, it would appear that in this real world application Java is
ridiculously slow. Of course, Python is doing the heavy lifting
with GMPY which is a compiled C program with a Python
wrapper. But so what? Maybe the reason I use Python is
BECAUSE the math module is compiled C. Duh. With Python/GMPY
I get the high level power I need for the algorithms without
sacrificing the low level muscle I need for the heavy arithmetic.

看看PyGame。



我的路上:)

最好
k



on my way :)

best
k





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

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