[Cython] CF based type inference

mark florisson markflorisson88 at gmail.com
Tue May 21 13:39:06 CEST 2013


On 21 May 2013 11:26, Vitja Makarov <vitja.makarov at gmail.com> wrote:
> Hi!
>
> Recently I've started work on new type inference engine. Now it's almost
> ready and I want to discuss it.
>
> It works like this: first infer type for each assignment then for whole
> entry. It has some advantages over previous algorithm:
>  - it handles assignment cycles, see test_swap() for example
>  - it can infer type using info about assignments on the whole entry:
>
> a = 1
> b = a
> a = "str"
>
> a is python object and b is integer.
>
> Here are testcases that show some new cases it can solve:
> https://github.com/vitek/cython/blob/_type_inference_new/tests/run/type_inference_new.pyx
>
> Here is branch for it
> https://github.com/vitek/cython/tree/_type_inference_new
>
> --
> vitja.
>
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> http://mail.python.org/mailman/listinfo/cython-devel
>

Hey Vitja,

Cool! How do you want to handle variable merge at control flow joins?
Would you promote (backwards incompatible), use a union type, or
object? E.g. what does this result in:

    x = 0
    for i in range(N):
        x += 0.2 * i
    print typeof(x)


More information about the cython-devel mailing list