[Cython] C methods broken?

Stefan Behnel stefan_ml at behnel.de
Wed Dec 3 06:58:06 CET 2008


Hi,

Kay Schluehr wrote:
> 
> cdef class ExtPoint:
>     cdef int x
>     cdef int y
> 
>     cdef convert(self, CPoint pt): 
>         self.x = pt.x
>         self.y = pt.y
> 
> cpdef test():
>     cdef CPoint pt
>     pt.x = random.randrange(100)
>     pt.y = random.randrange(100)
>     ep = ExtPoint()
>     convert(ep, pt)    # o.k   - compiles
>     ep.convert(pt)     # n.o.k - fails to compile

You forgot to

	cdef ExtPoint ep

so that Cython knows that ep.convert() even exists as a C method.
Otherwise, it considers it a Python method on an unknown Python object.

Stefan


More information about the Cython-dev mailing list