[Cython] CF based type inference

Vitja Makarov vitja.makarov at gmail.com
Thu May 10 11:34:08 CEST 2012


2012/5/9 Robert Bradshaw <robertwb at gmail.com>:
> On Wed, May 9, 2012 at 6:33 AM, Stefan Behnel <stefan_ml at behnel.de> wrote:
>> mark florisson, 09.05.2012 15:18:
>>> On 9 May 2012 14:16, Vitja Makarov wrote:
>>>> from cython cimport typeof
>>>>
>>>> def foo(float[::1] a):
>>>>    b = a
>>>>    #del b
>>>>    print typeof(b)
>>>>    print typeof(a)
>>>>
>>>>
>>>> In this example `b` is inferred as 'Python object' and not
>>>> `float[::1]`, is that correct?
>>>>
>>> That's the current behaviour, but it would be better if it inferred a
>>> memoryview slice instead.
>>
>> +1
>
> +1. This looks like it would break inference of extension classes as well.
>
> https://github.com/vitek/cython/commit/f5acf44be0f647bdcbb5a23c8bfbceff48f4414e#L0R336
>
> could be changed to check if it's already a py_object_type (or memory
> view) as a quick fix, but it's not as pure as adding the constraints
> "can be del'ed" to the type inference engine.
>

Here is fixed version:

https://github.com/vitek/cython/commit/0f122b6dfb6d0c7932b08cc35cdcc90c3c30257b#L0R334


-- 
vitja.


More information about the cython-devel mailing list