Re: python speed



Krystian wrote:
> 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.
> >
> >Why would we want Python to be as fast as Java when it's already faster?
>
> hm... i came across this site:
> http://shootout.alioth.debian.org/benchmark.php?test=all&lang=java&lang2=python&sort=fullcpu
>
> could you take an attitude with regard to this benchmark?

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.

>
> >Take a look at PyGame.
>
> on my way :)
>
> best
> k

.



Relevant Pages

  • Re: Java -> ActionScript?
    ... Lage sein Java zu verdrängen? ... In Ruby geht das ja, ... Andere Sprachen wie Python oder auch Ruby sind eh ... Die Syntax sollte jedoch das Programm nicht begraben. ...
    (de.comp.lang.java)
  • Re: Python or Java or maybe PHP?
    ... Python or Java? ... Ruby (with Rails, of course, as the server-side framework), Python (many ... this cuts both ways (once you've decided on Java as the language you ...
    (comp.lang.python)
  • Re: iniziare a programmare
    ... studiare python o ruby (anche se ora vorrei leggere qualcosa su python, ... javascript(ma quest ultimi non sono utili al fine del post) ... Ruby si accorge immediatamente di cosa intendo quando voglio dire che ... Java è macchinoso. ...
    (it.comp.macintosh)
  • Re: why is "self" used in OO-Python?
    ... When you define a method in Java there is an implicit 'this' passed to the ... Python cannot tell when you define a function whether the function ... Some languages don't allow you to encapsulate ...     def phone: ...
    (comp.lang.python)
  • Re: Basic inheritance question
    ... used 'this' in C++ and Java. ... but in Python it doesn't. ... you meant "in languages that has implicit instance reference available in methods"? ...
    (comp.lang.python)