Robert Bradshaw, 30.04.2013 06:59:
> I think the transformation
>
> print L[-1]
>
> to
>
> cdef int x = -1
> print L[x]
>
> or
>
> cdef enum X:
> x = -1
>
> [... lots of intervening code, possibly in another file ...]
>
> print L[x]
>
> should not cause any semantic change
+1
> and quite possibly a future optimization would "undo" it
I attached a patch attempt that's been resting on my hard drive for a
while. It's not a safe optimisation yet because it hits too many cases. The
main goal was to get rid of redundant variables in closures, which have a
performance impact, especially in generators. Note that the patch
completely lacks tests, especially for all those little corner cases that
can appear in closures.
If someone wants to give it a try, I think it's worth it.
Stefan