Kurt Smith wrote: > On Tue, May 19, 2009 at 7:01 AM, OUARDA MEHDI wrote: > [snip] >> >> cdef class RzRyRxJoint(LinearConfigurationSpaceJoint): >> >> @property >> cpdef jacobian(self): #mes modifs....... >> ... > > There's a special syntax to define properties for extension types. > > Instead of > > --------------------------------------------------------- > @property > def ndof(self): > return 3 > --------------------------------------------------------- > You'd do: > > --------------------------------------------------------- > property ndof: > def __get__(self): > return 3 > ----------------------------------------------------------
While this is true, it doesn't really solve the problem that the OP wanted to use a property for a cpdef method. The problem here is that 'c(p)def' methods are C functions and you cannot wrap them in a property. What you can do, however, is to move the property code into a cdef method (not cpdef) and use that in your own code, and then additionally declare a property as Kurt described above, which simply calls the cdef method. That way, you get fast access from your Cython code and property access from Python code. I'm not even sure if it's technically possible to 'unroll' properties in Cython, so that you'd get the equivalent of a cpdef method for properties. There may be some tricky inheritance issues involved. At least, you can't just call into the implementing descriptor methods. Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
