为什么python比java慢? [英] why python is slower than java?

查看:325
本文介绍了为什么python比java慢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个愚蠢的问题,但除了对动态打字的惩罚外,还有其他任何真正的原因,Python比Java慢吗?


maurice

This may be a dumb thing to ask, but besides the penalty for dynamic
typing, is there any other real reasons that Python is slower than Java?

maurice

推荐答案

Maurice LING写道:
Maurice LING wrote:
这可能是一个愚蠢的问题,但除了罚款对于动态打字,有没有其他任何真正的原因,Python比Java慢?

maurice
This may be a dumb thing to ask, but besides the penalty for dynamic
typing, is there any other real reasons that Python is slower than Java?

maurice




在工作,我们使用java和python。我们有使用swing的项目和其他使用wxpython的项目。我们的应用程序可以执行
密集的io和其他执行密集cpu的应用程序。我们还没有发现python比java慢。事实上,当它来到gui'时,我们的摇摆应用程序会永远地使用它。启动时以及当垃圾收集器启动时,整个应用程序只需

冻结约15秒。我们的wxpython应用程序,启动并感觉更快,更快捷。你能展示一个

的例子,其中python'的'慢'是什么?速度与java'的快速相比速度对您的应用程序产生了负面影响或者

是否以任何方式显着?我知道这是你发布的一个拖钓问题,但我其实非常感兴趣

知道你为什么这么说。


谢谢,


bryan



at work, we use java and python. we have projects using swing and others using wxpython. we have applications that do
intensive io and others that do intensive cpu. we have not found that python is slower than java. in fact, when it
comes to gui''s, our swing apps take "forever" to startup and when when garbage collector starts, the whole app just
freezes for about 15 seconds. our wxpython apps, start right up and "feel" faster and snappier. can you show an
example of where python''s "slow" speed as compared to java''s "fast" speed has negatively impacted your application or
has been noticable in any way? i know this is a trolling question you have posted, but i''m actually very interested
knowing why you have said this.

thanks,

bryan


在工作中,我们使用java和python。我们有使用swing的项目和其他使用wxpython的项目。我们的应用程序需要密集的io和其他执行密集cpu的应用程序。我们还没有发现python比java慢。事实上,当涉及到gui'时,我们的摇摆应用程序会永远地使用它。启动时以及当垃圾收集器启动时,整个
应用程序只会冻结大约15秒。我们的wxpython应用程序,启动正确
向上和感觉更快,更快捷。你能举例说明py py&&slow slow slow slow slow slow slow slow slow slow slow速度与java'的快速相比速度对您的应用程序产生了负面影响,或者以任何方式表现出来?我知道这是你发布的一个拖钓问题,但我其实非常感兴趣
知道你为什么这么说。

谢谢,

bryan
at work, we use java and python. we have projects using swing and
others using wxpython. we have applications that do intensive io and
others that do intensive cpu. we have not found that python is slower
than java. in fact, when it comes to gui''s, our swing apps take
"forever" to startup and when when garbage collector starts, the whole
app just freezes for about 15 seconds. our wxpython apps, start right
up and "feel" faster and snappier. can you show an example of where
python''s "slow" speed as compared to java''s "fast" speed has negatively
impacted your application or has been noticable in any way? i know this
is a trolling question you have posted, but i''m actually very interested
knowing why you have said this.

thanks,

bryan




谢谢,我只想说我对拖钓毫无兴趣。


首先,我想在某些情况下,在很多情况下,python比java慢得多。虽然我可能错了......当我在Google搜索时进行了搜索,这就出现了......

http://twistedmatrix.com/users/glyph...n-vs-java.html


虽然 http://page.mi.fu-berlin.de/~prechel.../jccpprtTR.pdf

显示恰恰相反。


我现在需要做的是需要速度(并且用文件处理
),而无需用户的干预。因此,关于用户延迟

时间的部分不在等式中。我的选择归结为Python或Java。


干杯

maurice



Thanks, lets just say that I have no interest in trolling.

1st of all, I thought it is somehow common knowledge that python is
slower than java in many cases. Though I may be wrong... When I do a
Google search, this came up...

http://twistedmatrix.com/users/glyph...n-vs-java.html

although http://page.mi.fu-berlin.de/~prechel.../jccpprtTR.pdf
showsjust the opposite.

What I need to work on now is something that requires speed (and dealing
with files), without user''s intervention. So the part about users'' delay
time is not in the equation. My choices boils down to Python or Java.

Cheers
maurice


Maurice LING写道:
Maurice LING wrote:
在工作中,我们使用java和python。我们有使用swing的项目和其他使用wxpython的项目。我们的应用程序需要密集的io和其他执行密集cpu的应用程序。我们还没有发现python比java慢。事实上,当涉及到gui'时,我们的摇摆应用程序会永远地使用它。启动时以及当垃圾收集器启动时,整个
应用程序只会冻结大约15秒。我们的wxpython应用程序,启动正确
向上和感觉更快,更快捷。你能举例说明py py&&slow slow slow slow slow slow slow slow slow slow slow速度与java'的快速相比速度对您的应用程序产生了负面影响,或者是否以任何方式显着?我知道这是你发布的一个拖钓问题,但我知道为什么你这么说非常感兴趣。

谢谢,

bryan
at work, we use java and python. we have projects using swing and
others using wxpython. we have applications that do intensive io and
others that do intensive cpu. we have not found that python is slower
than java. in fact, when it comes to gui''s, our swing apps take
"forever" to startup and when when garbage collector starts, the whole
app just freezes for about 15 seconds. our wxpython apps, start right
up and "feel" faster and snappier. can you show an example of where
python''s "slow" speed as compared to java''s "fast" speed has
negatively impacted your application or has been noticable in any
way? i know this is a trolling question you have posted, but i''m
actually very interested knowing why you have said this.

thanks,

bryan



谢谢,我只想说我对拖钓毫无兴趣。

首先,我认为它是某种常见的知识,python是
在很多情况下比java慢。虽然我可能错了......当我进行谷歌搜索时,这就出现了......

http://twistedmatrix.com/users/glyph...n-vs-java.html

尽管 http:// page。 mi.fu-berlin.de/~prechel.../jccpprtTR.pdf
显示恰恰相反。

我现在需要做的是需要速度的东西(无需用户干预即可处理文件。因此关于用户延迟时间的部分不在等式中。我的选择归结为Python或Java。

欢呼
maurice


Thanks, lets just say that I have no interest in trolling.

1st of all, I thought it is somehow common knowledge that python is
slower than java in many cases. Though I may be wrong... When I do a
Google search, this came up...

http://twistedmatrix.com/users/glyph...n-vs-java.html

although http://page.mi.fu-berlin.de/~prechel.../jccpprtTR.pdf
showsjust the opposite.

What I need to work on now is something that requires speed (and dealing
with files), without user''s intervention. So the part about users'' delay
time is not in the equation. My choices boils down to Python or Java.

Cheers
maurice




但你并不是说_what_需要速度以及您对项目的要求。你在这里过于笼统,所以任何人都可以真正帮助你。至于使用文件,我宁愿在python中这样做而不是

java。我可能错了,但我认为java的文件IO几乎是c的薄包装。所以我不认为你会发现python'的文件IO与java'相比有任何速度问题。另外,只是为了好玩,在java中写下以下完整的

工作python程序:


导入时间

t = time.time ()

s = open(''in.txt'')。read()

open(''out.txt'',''w'')。写(s)

打印time.time() - t


(顺便说一下......我能编写上面的python代码行没有参考手册:)


如果不是太麻烦,请你在这里发布你的代码以及上述代码的时间结果和

你的java代码?你可以测试一个小文件和一个大文件。


谢谢,


bryan



but you aren''t saying exactly _what_ requires speed and exactly what your requirements for the project is. you are being
way too general here for anyone to really help you. as for working with files, i much rather do that in python than
java. i may be wrong, but i thought java''s file IO was pretty much a thin wrapper over c. so i don''t think you will
have any speed problems with python''s file IO compared to java''s. also, just for fun, write the following fully
working python program in java:

import time
t = time.time()
s = open(''in.txt'').read()
open(''out.txt'', ''w'').write(s)
print time.time() - t

(by the way...i was able to write the above lines of python code without referring to a manual :)

if it''s not too much trouble, could you please post your code here along with the time results for the above code and
your java code? you can test a small file and a large one.

thanks,

bryan


这篇关于为什么python比java慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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