Nuitka now supports Python 3.2

Stefan Behnel stefan_ml at behnel.de
Thu Feb 28 14:03:23 EST 2013


Steven D'Aprano, 28.02.2013 14:23:
> On Thu, 28 Feb 2013 08:07:55 +0100, Stefan Behnel wrote:
> 
>> Steven D'Aprano, 26.02.2013 13:18:
>>> Nuitka is an implementation of Python written in C++. At the moment it
>>> is claimed to be about 2.5 times as fast as CPython running the pystone
>>> benchmark.
>>
>> Could we please get to the habit of not citing results of "benchmarks"
>> that *any* static analysis phase will just optimise away either
>> completely or in major parts?
> 
> Are you saying that the pystone benchmark contains such an empty loop?
> 
> Do you know for a fact that Nuitka performs such an optimization based on 
> static analysis?
> 
> Are you saying that this one test is so significant that it invalidates 
> the entire pystone benchmark?

Yes, this effect renders most of the "benchmark" (and of similar
"benchmarks") useless, and yes, Nuitka obviously does static analysis (it's
a static compiler), just like the C++ compiler that passes over the
generated code right afterwards. It's nothing special. In fact, CPython is
special in that it (deliberately) does not apply this kind of
optimisations. Everyone else does, not so much because it's required but
because it's so simple to do when you need static analysis anyway in order
to do whatever kind of static code translation. And any static compiler
needs to do static analysis, at least to some extent.

The problem with this kind of "benchmarks" is that they were written for
CPython and are entirely based on the assumption that the runtime does not
apply any optimisations. As soon as this assumption fails, the "benchmarks"
are no longer meaningful. Specifically, they are completely useless for
comparing different runtimes.

In Cython, we even deliberately do *not* implement several possible
optimisations because we know that they would only apply to bad
"benchmarks", not to real-world code, and would thus only bloat our
compiler code more than they would help anyone. It's important to find a
good balance between complexity and performance, and I actually find that
CPython has made a very reasonable choice here. Its implementation is
intentionally simple in many aspects (especially its VM), and less so in
others (e.g. data types).

Stefan





More information about the Python-list mailing list