sturlamolden, 04.07.2010 05:30:
I was just looking at Debian's benchmarks. It seems LuaJIT is now (on
median) beating Intel Fortran!
C (gcc) is running the benchmarks faster by less than a factor of two.
Consider that Lua is a dynamically typed scripting language very
similar to Python.
Sort of. One of the major differences is the "number" type, which is (by
default) a floating point type - there is no other type for numbers. The
main reason why Python is slow for arithmetic computations is its integer
type (int in Py3, int/long in Py2), which has arbitrary size and is an
immutable object. So it needs to be reallocated on each computation. If it
was easily mappable to a CPU integer, Python implementations could just do
that and be fast. But its arbitrary size makes this impossible (or requires
a noticeable overhead, at least). The floating point type is less of a
problem, e.g. Cython safely maps that to a C double already. But the
integer type is.
So it's not actually surprising that Lua beats CPython (and the other
dynamic languages) in computational benchmarks.
It's also not surprising to me that a JIT compiler beats a static compiler.
A static compiler can only see static behaviour of the code, potentially
with an artificially constructed idea about the target data. A JIT compiler
can see the real data that flows through the code and can optimise for that.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list