[Cython] separate 'initial typing' phase?
Stefan Behnel
stefan_ml at behnel.de
Fri Dec 19 21:35:28 CET 2008
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
>> That's where the major tree restructuring takes place, right?
>> That's most
>> of what is currently in Optimize.py, plus the with-statement.
>
> Yep.
>
>>> - [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).
>>> - type analysis and coercions
>> What would this step do with the already known or previously assigned
>> types? I guess that's node specific, right?
>
> This would essentially be much of what analyse_types does now for non-
> name/attribute nodes.
I think so, too.
>>> - code generation
>>>
>>> One issue is that in the current code base, there is a lot of code
>>> that early on branches on whether or not the type is a python type or
>>> not. I think much of this can be differed to right before code
>>> generation.
>> I don't fear this that much. According to the main pipeline, we
>> already
>> have a lot of the code running before type analysis. The
>> refactoring would
>> be more about moving interesting stuff out of the type analysis
>> phase and
>> into the earlier steps.
>
> True. Let's try and hit a stable 0.11 before we attack this too much
> though.
:) +1
The only major bug I currently see is that you can't short-cut out of the
with-statement (return/break/continue). But that's been broken since the
beginning and isn't trivial to fix.
We should try to get some of the remaining 0.11 bugs fixed and do an alpha
release soon.
Stefan
More information about the Cython-dev
mailing list