Hi,

Lisandro Dalcin wrote:
> On 5/10/08, Greg Ewing <[EMAIL PROTECTED]> wrote:
>> Lisandro Dalcin wrote:
>>  > I believe you are right, it seems a bug,
>>  >
>>
>>> cdef class myTest
>>  >     def __add__(myTest self, other): # note declaration: myTest self
>>  >         return self.thisPtr.add(other)
>>
>>
>> It's not a bug. With extension types, the first argument
>>  of operator methods isn't necessarily self, so it's not
>>  automatically typed as such.
>
> What do you understand for 'A parameter named self is of the type the
> method belongs to'. Anyway, do not you believe the current behavior is
> a bit counter-intuitive?

I agree that it is counter-intuitive for Python users, but these things are
also non-trivial in Python. The Python API actually distinguishes between
__add__ etc. and __radd__ etc., which are merged into a single function in
Pyrex. Maybe that should be mentioned in the docs.

http://docs.python.org/ref/numeric-types.html

I think anyone who proves to be able to implement a complete numeric type in
Python should be able to implement it in Pyrex - possibly minus some fixes in
the Pyrex/Cython documentation. But you definitely will have to read the docs
to get this right in Python *and* in Pyrex.

Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to