Hello,

It used to be that defining __int__ allowed an object to be accepted as
an integer from various functions, internal and third-party, thanks to
being implicitly called by e.g. PyLong_AsLong.

Today, and since bpo-37999, this is no longer the case.  It seems that
__int__ has now become a strict equivalent to __trunc__.  Of course,
user code can still look up and call the __int__ method explicitly (or
look up the nb_int slot, in C), but that's a bit of anti-pattern.

Is there a point in having three special methods __index__, __int__ and
__trunc__, if two are them are practically interchangeable?

Regards

Antoine.


_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/K6TEYMDY5NEDV4MHH6EGIOQWDOAKSPJV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to