why python is slower than java?

Bryan belred1 at yahoo.com
Fri Nov 5 02:54:50 EST 2004


Maurice LING wrote:
> 
>> 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
> 
> 
> 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/rant/python-vs-java.html
> 
> although http://page.mi.fu-berlin.de/~prechelt/Biblio/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

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



More information about the Python-list mailing list