[Cython] Beginner-friendly tickets

Dag Sverre Seljebotn dagss at student.matnat.uio.no
Mon Mar 16 08:25:50 CET 2009


Prajwal Suhas P wrote:
> I changed the code to
> 
> cdef int g():
>     print "g called"
>     return 3
> 
> def f():
>     for i in range(g()):
>         print i
>     print i
> 
> we get the right output here
> 
> g called
> 0
> 1
> 2
> 2
> 
> the c output changes(and is wrong) when we declare a "cdef int i" before 
> the for loop.i missed this part initially.

Yes, when "i" is not typed as int, the Python "range" function is 
called, which gives the right behaviour. The task is to make Cython do 
the right thing when i is declared "cdef int" as well.


-- 
Dag Sverre


More information about the Cython-dev mailing list