17.12.20 21:58, Ethan Furman пише:
> On 12/17/20 11:09 AM, Chris Angelico wrote:
>> "a+b" is NOT implemented as "a.__add__(b)", nor as "type(a).__add__(b)"!
> 
> Okay, what is it implemented as?

First, it can use not only method __add__ of the type of a, but also
method __radd__ of the type of b.

Second, the lookup of __add__ differs from both a.__add__ and
type(a).__add__. It differs from a.__add__ because skips an instance
dict and __getattr__. It differs from type(a).__add__ because does not
fallback to methods of the metaclass.

This all is pretty complicated.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/ADK5DGEEPPFQ5XY55GUQWRUY3QBDXUSD/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to