31 Oct
2019
31 Oct
'19
10:40 a.m.
Currently __trunc__ is used for two purposes: * In math.trunc() which just calls __trunc__. * In int() and PyNumber_Long() as a fallback if neither __int__ nor __index__ are implemented. Unlike to __int__ and __index__ there is not a slot corresponding to __trunc__. So using it is slower than using __int__ or __index__. float and Decimal implement __int__ and __trunc__ by the same code. Only Fraction implements __trunc__ but not __int__. I propose to deprecate the falling back to __trunc__ for converting to int and remove it in future. Fraction should implement __int__. We cannot use __trunc__ for setting the nb_int slot because it can return non-int.