[Pyrex] Type conversion to arguments for a C method

Michael Hordijk hoffbrinkle at hotmail.com
Mon Oct 17 17:44:15 CEST 2005


Alrighty,
	Continuing with my project now that things don't segfault on __init__, 
I think I've run into a missing type conversion.  Exawple through code 
is probably easiest.

[[[
cdef class test(ListType):
     cdef __getitem__(self, i):
         cdef int j
         j = i
         print j
         return None
]]]

yields:

[[[
 >>> import testMod
 >>> a = testMod.test()
 >>> a[0]
0
]]]

So far so good.  Now:

[[[
cdef class test(ListType):
     cdef __getitem__(self, int i):
         print i
         return None
]]]

yields:

[[[
 >>> import testMod
 >>> a = testMod.test()
 >>> a[0]
134537076
]]]

Huh.  I couldn't find anything in the documentation that said this type 
conversion would not automatically happen.  Did I miss something?

- michael




More information about the Pyrex mailing list