On Sat, Nov 2, 2019 at 1:54 PM Nick Coghlan <ncoghlan@gmail.com> wrote:
On Fri., 1 Nov. 2019, 8:10 am Guido van Rossum, <guido@python.org> wrote:
It seems a good idea to add __int__ to Fraction, but if you stop falling back to __trunc__, won't that cause backwards compatibility issues? I'd say looking for __trunc__ if the alternative is failing isn't so bad.
Aye, converting a case where code is slower than it needs to be to an outright failure isn't a good trade-off.
I find int() falling back to __trunc__() surprising, actually. Removing it will break backwards-compatibility, but implementing __int__() is an easy fix. Perhaps we could run a code search for classes implementing __trunc__ but not __int__? Speeding up int(str), as well as slightly simplifying the language, are rather good arguments in favor of this. - Tal