[Tutor] Loop comparison
cloudneozero at gmail.com
Fri Apr 16 08:50:58 CEST 2010
A friend of mine suggested me to do the next experiment in python and Java.
It's a simple program to sum all the numbers from 0 to 1000000000.
result = i = 0
while i < 1000000000:
result += i
i += 1
The time for this calculations was huge. It took a long time to give
the result. But, the corresponding program in Java takes less than 1
second to end. And if in Java, we make a simple type check per cycle,
it does not take more than 10 seconds in the same machine. I was not
expecting Python to be faster than Java, but it''s too slow. Maybe
Java optimizes this case and Python doesn't. Not sure about this.}
More information about the Tutor