Live data from Hacker News

Make Lisp 15x faster than Python or 4x faster than Java

blog.postabon.com

81–90 of 100 posts

Re: Make Lisp 15x faster than Python or 4x faster than Java

#83
post #69

Earlier quoted context omitted.

Great stuff thanks! $Weekend--;

By tomorrow you'll switch to (decf weekend)

And after randomly mutating variables breaks a few of your programs, you'll switch to "(plan-weekend-time (-1 weekend))".

Re: Make Lisp 15x faster than Python or 4x faster than Java

#84
post #44

And of course, Haskell can be faster than all of these.

Not always: http://shootout.alioth.debian.org/u32/benchmark.php?test=all...

I don't think that "Not always" is a valid answer to "Haskell can be faster"; or rather, in the sense that it is a valid answer, I don't think your link proves it.

Re: Make Lisp 15x faster than Python or 4x faster than Java

#85
post #21

I ran the Python script through Shedskin, a partial Python implementation that compiles Python to machine code via an intermediate layer of C++. I did not have to declare any types for any variables, or add declarations for speed/safety; Shedskin automatically determined the types. The finished program went down in runtime from 533.7s on my machine, to 24.42 seconds. If we adjust for machine speed (since the author's…

There may be hundreds of man years of research gone into LISP, but a lot of that research found its way into shedskin too. And the Self research is in there too. And his own research (Shedskin was originilly his Masters).

Re: Make Lisp 15x faster than Python or 4x faster than Java

#87
post #77

Earlier quoted context omitted.

Java and Python are actually doing all of the work to compute their trigonometric functions Not true in the case of CPython. It uses the underlying C implementation. See line 270 onwards. http://www.google.com/codesearch/p?hl=en#2T6lfGELm_A/trunk/M...

Interesting.. well, I'd think the trig functions would be by far the most expensive part of that program. Is Python really that much slower for control structures? That's literally the only other computation there.

Well, every instruction in a Python program requires running through the interpreter loop. Then you have to decode, get the opcode arguments, then actually do the operation. For calling C functions from Python, you also have to extract the C types, call the C function, and wrap the result back up. Its not hugely slow, but yeah, it adds up, and its fairly easy to see why it compares poorly to compiled versions.

Re: Make Lisp 15x faster than Python or 4x faster than Java

#89

And of course, Haskell can be faster than all of these.

http://gist.github.com/289645

I coded it in haskell, and it is faster, if it's a correct translation. Without parallelizing, it clocks at 1.8 seconds, compiled with $ ghc --make. If anyone plans to compile this you'll need to $ cabal install geodetic, before $ ghc --make filename.hs

1.8 Seconds seems a little too fast though...

Re: Make Lisp 15x faster than Python or 4x faster than Java

#90
post #52

Isn't it a much better idea to pick a distance comparison algorithm that's not so staggeringly slow to begin with? Why not convert (i.e. pre-compute) the lat/lons to 3-vectors (origin center of the earth) and then compare distances by pythagoras, no fuss, muss or trig and you can even skip the square root. If you need to display an actual accurate distance you can do the (significantly smaller amount of) trig to get…

It's valid if you want to understand what'll happen when you start getting random (lat,long) pairs thrown at you that you can't precompute.
Post reply on HN