Mailing List Archive

No right operator in tp_as_number?
I checked the documentation:
https://docs.python.org/3/c-api/typeobj.html#number-structs
and it seems that, in the Python C API, the right operators do not exist.
For example, there is nb_add, that in Python is __add__, but there's
no nb_right_add, that in Python is __radd__

Am I missing something?
--
https://mail.python.org/mailman/listinfo/python-list
Re: No right operator in tp_as_number? [ In reply to ]
On 2021-11-20 17:45, Marco Sulla wrote:
> I checked the documentation:
> https://docs.python.org/3/c-api/typeobj.html#number-structs
> and it seems that, in the Python C API, the right operators do not exist.
> For example, there is nb_add, that in Python is __add__, but there's
> no nb_right_add, that in Python is __radd__
>
> Am I missing something?
>
A quick Google came up with this:

Python's __radd__ doesn't work for C-defined types
https://stackoverflow.com/questions/18794169/pythons-radd-doesnt-work-for-c-defined-types

It's about Python 2.7, but the principle is the same.
--
https://mail.python.org/mailman/listinfo/python-list