[Cython] separate 'initial typing' phase?

Stefan Behnel stefan_ml at behnel.de
Fri Dec 19 17:06:37 CET 2008


Hi,

I noticed that many of the transforms I implemented lately are supposed to
run after type analysis for mainly one reason: they must be able to
distinguish between builtin types and other stuff. For example, they must
know that "range" denotes the builtin range function/type, that [] or a
list comprehension return a list, and that a variable declared 'cdef dict'
can only contain a dict (ok, possibly None).

Would it make sense to add something like an initial pre-typing step that
tries to annotate as many nodes as possible with their definite type, so
that the transforms could run between this step and the final type
analysis? That would make the final tree available for type analysis (and
thus avoid unnecessary coercions), and still provide the required type
information to transforms.

Stefan


More information about the Cython-dev mailing list