why python is slower than java?

Pythogoras noreal at email.org
Sun Nov 7 08:55:46 EST 2004


"Bryan" <belred1 at yahoo.com> wrote:

>  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

OK. I will rewrite it in Java.

///
long t = currentTimeMillis();
tryCopyFile("in.txt","out.txt");
out.println( (currentTimeMillis() - t) / 1000);
///

You lost. The Java-version is shorter!
I didn't count import- and import static-statements
because Eclipse cares about imports automatically.


But maybe you want to have something more fun?
How about that?
    read autoexec.bat,
    sort the lines
    create sorted_autoexec.bak

///
File source = new File("c:/autoexec.bat");
File destination = new File("c:/sorted_autoexec.bak");

String[] lines = readLines(source);
lines = sort(lines);
write(destination,lines);
///

You lost.
You Pythonistas are a bunch of losers.
And your language is dog-slow.
Eeeeeek.

And try to write Eclipse with your Mickey-Mouse-language!

<j>
Pythogoras






More information about the Python-list mailing list