[Cython] Constant folding

Robert Bradshaw robertwb at math.washington.edu
Sat Jun 11 02:21:42 CEST 2011


On Fri, Jun 10, 2011 at 8:22 AM, Vitja Makarov <vitja.makarov at gmail.com> wrote:
> Hi!
>
> When CF is there it is possible to improve constant folding.

Do you have some examples? I can see that

    a = 1.0
    b = sin(a)

could now be optimized, but I don't see that being a common pattern.
(Also, if a is typed, gcc is likely to already be able to do this.)

> Some NameNode references could be easily replaced by appropriate ConstNode.
>
> Could that help GCC to produce faster code?

Possibly a first (and more fruitful) step to investigate would be more
local type inference (e.g a variable might be a double within a block,
and only need to be used as/store an object elsewhere.

- Robert


More information about the cython-devel mailing list