[Cython] separate 'initial typing' phase?
Stefan Behnel
stefan_ml at behnel.de
Fri Dec 19 21:48:45 CET 2008
Stefan Behnel wrote:
> Robert Bradshaw wrote:
>> On Dec 19, 2008, at 11:46 AM, Stefan Behnel wrote:
>>> Robert Bradshaw wrote:
>>>> - Type declared variables (this includes all "cdef T x" and builtins)
>>>> - high-level transformations
>>>> - [type inference on untyped variables]
>>>> - lower-level transformations
>>> Would the constant folding go here as well? In the current state, it
>>> doesn't take much care about types (or even type casts), although it
>>> probably should do that for correctness.
>> Yeah. Typing constants would happen in the phase above, so it could
>> probably go even higher.
>
> It actually has to, now that you say it. It needs to be done right after
> type declaration and before the major tree transforms run, as some of them
> need access to pre-evaluated expression results (the step in the for-range
> transform, for instance).
Although this might have implications. When a transform changes a subtree,
and a later transform reads the constant expression of its parent...
I doubt that there will be many cases where we actually change the
structure of a subtree that was already found constant, though, especially
with tree modifications that change the constant value. So maybe this is a
non-issue right from the start.
Stefan
More information about the Cython-dev
mailing list