13 Oct
2021
13 Oct
'21
5:10 p.m.
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.