Sébastien Sablé, 13.01.2011 13:45:
> Thanks for Cython it is a great tool that I use everyday in my work.
>
> I wanted to test cython 0.14.1 before its release and I found a
> regression related to type inference compared to 0.13 that impacts my
> project.
>
> The following code will not correctly compile:
>
> #cython: infer_types=True
>
> cdef get_field_flags():
> flags = []
> append = flags.append
> append('fetched')
> return flags
... with the obvious (and much faster) work-around to not use the bound
method instead of calling it directly on the list object.
> cythoning magnum/magpy.pyx to magnum/magpy.c
>
> Error compiling Cython file:
> ------------------------------------------------------------
> ...
> #cython: infer_types=True
>
> cdef get_field_flags():
> flags = []
> append = flags.append
> append('fetched')
> ^
> ------------------------------------------------------------
>
> magnum/magpy.pyx:6:10: Call with wrong number of arguments (expected 2,
> got 1)
>
> The same code would work great with cython 0.13 and it would work with
> 0.14.1 if I remove the infer_types=True line.
Thanks for the report. It's quite possible that the type inference
mechanism now assumes that the bound method is actually the C-API function
replacement, i.e. the C function PyList_Append(). That's the wrong thing to
infer here as it cannot be made to work.
Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev