Willem Jan Palenstijn, 17.01.2011 15:04:
> When using a decorator on an arithmetic operator such as __mod__ in a cdef
> class, the method __mod__ is properly replaced, but the corresponding
> operator doesn't seem to be. See below for an example.
>
> Am I doing something wrong, or is this indeed not supported?

It's not supported. For cdef classes, Cython generates a C function of the 
appropriate signature and stuffs it into the C slot of the Python type. 
Since we can't know what the decorator actually does with the function, we 
can't just call it and expect that the return value is compatible with that 
slot.

It should be possible to fake this feature, i.e. to actually generate a 
wrapper function for the slot instead that simply calls whatever the 
decorator actually returned. However, that requires a dedicated 
implementation and nothing has been done in that direction.

I created a ticket for this:

http://trac.cython.org/cython_trac/ticket/648


> It would be nice if cython could raise a warning or error in this situation.

Absolutely.

http://trac.cython.org/cython_trac/ticket/649

Stefan
_______________________________________________
Cython-dev mailing list
Cython-dev@codespeak.net
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to