[Pyrex] Special methods do not type cast 'self'

Stefan Behnel behnel_ml at gkec.informatik.tu-darmstadt.de
Tue Jul 18 18:00:48 UTC 2006



Stefan Behnel wrote:
>     cdef class _NumberElement(BaseClass):
>         cdef _value(self):
>             return 1
>         def __add__(self, other):
>             return self._value() + other
> 
> This does not work. It generates this code in the __add__ function:
> 
> [...]
> __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n__value); if [...]
> 
> which obviously fails to find the C method. I can work around this with a type
> cast, but I think this should be fixed.

Sorry, I just found it in the docs. This is intentional.

http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/version/Doc/special_methods.html

Stefan



More information about the Pyrex mailing list