On 4 Jul, 10:03, Stefan Behnel <stefan...@behnel.de> wrote: > 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.
That is why Lua got it right. A floating point type has a mantissa and can duck type an integer. MATLAB does the same. Sturla 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