[Python-Dev] chained assignment weirdity

Terry Reedy tjreedy at udel.edu
Wed Nov 7 20:08:33 CET 2012


On 11/7/2012 9:54 AM, Guido van Rossum wrote:

> Hm. I really don't think that is a good development for Python to
> compromise in the area of expression evaluation order where side
> effects are involved.

I agreee. I think Python's simple left to right evaluation order is one 
of its virtues.

> A good compiler should be able to detect the
> absence of potential side effects. E.g. it might reorder when only
> constants and simple variable references are present, or (in the case
> of a JIT, which has run-time type information) when it knows enough
> about the types of the operands involved to determine that operations
> like getattr or getitem are guaranteed side-effect-free.

I call this the 'as-if' rule: the compiler can take shortcuts if the 
result is 'as-if' no shortcut.

-- 
Terry Jan Reedy



More information about the Python-Dev mailing list