Hi,
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 would be nice if cython could raise a warning or error in this situation.
(Or even better if it would override the operator, but I don't know how
feasible that would be given python's special treatment of these arithmetic
slots.)
Thanks,
Willem Jan
class DEC:
def __init__(self, f):
self._f = f
def __call__(self, x):
print "DEC.__call__ called"
cdef class X:
@DEC
def __mod__(self, x):
print "X.__mod__ called"
class Y:
@DEC
def __mod__(self, x):
print "Y.__mod__ called"
> a = X()
> b = Y()
> a % 2
X.__mod__ called
> b % 2
DEC.__call__ called
> a.__mod__(2)
DEC.__call__ called
> b.__mod__(2)
DEC.__call__ called
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev