This release is the first follow-up with a focus on optimization. The major highlight is progress towards SSA form in the node tree.
Also a lot of cleanups have been performed, for both the tree building, which is now considered mostly finished, and will be only reviewed. And for the optimization part there have been large amounts of changes.
Python 3.3 experimental support
Python 3.2 support has been expanded.
The Python 3.2 on Ubuntu is not providing a helper function that was used by Nuitka, replaced it with out own code.
Default values were not "is" identical.
def defaultKeepsIdentity( arg = "str_value" ): print arg is "str_value" defaultKeepsIdentity()
This now prints "True" as it does with CPython. The solution is actually a general code optimization, see below. Issue#55
Usage of unicode built-in with more than one argument could corrupt the encoding argument string.
An implementation error of the unicode was releasing references to arguments converted to default encoding, which could corrupt it.
Assigning Python3 function annotations could cause a segmentation fault.
Improved propagation of exception raise statements, eliminating more code. They are now also propagated from all kinds of expressions. Previously this was more limited. An assertion added will make sure that all raises are propagated. Also finally, raise expressions are converted into raise statements, but without any normalization.
# Now optimizing: raise TypeError, 1/0 # into (minus normalization): raise ZeroDivisionError, "integer division or modulo by zero" # Now optimizing: (1/0).something # into (minus normalization): raise ZeroDivisionError, "integer division or modulo by zero" # Now optimizing: function( a, 1/0 ).something # into (minus normalization), notice the side effects of first checking # function and a as names to be defined, these may be removed only if # they can be demonstrated to have no effect. function a raise ZeroDivisionError, "integer division or modulo by zero"
There is more examples, where the raise propagation is new, but you get the idea.
Conditional expression nodes are now optimized according to the truth value of the condition, and not only for compile time constants. This covers e.g. container creations, and other things.
# This was already optimized, as it's a compile time constant. a if ( "a", ) else b a if True else b # These are now optimized, as their truth value is known. a if ( c, ) else b a if not (c, ) else b
This is simply taking advantage of infrastructure that now exists. Each node kind can overload "getTruthValue" and benefit from it. Help would be welcome to review which ones can be added.
Function creations only have side effects, when their defaults or annotations (Python3) do. This allows to remove them entirely, should they be found to be unused.
Code generation for constants now shares element values used in tuples.
The general case is currently too complex to solve, but we now make sure constant tuples (as e.g. used in the default value for the compiled function), and string constants share the value. This should reduce memory usage and speed up program start-up.
The quicker release is mostly a consolidation effort, without actual performance progress. The progress towards SSA form matter a lot on the outlook front. Once this is finished, standard compiler algorithms can be added to Nuitka which go beyond the current peephole optimization.