On 10/14/21, Antoine Pitrou <anto...@python.org> wrote: > On Wed, 13 Oct 2021 17:00:49 -0700 > Guido van Rossum <gu...@python.org> wrote: >> >> so int() can't call __trunc__ (as was explained earlier in >> the thread).
I guess this was meant to be "*just* call __trunc__". It's documented that the int constructor calls the initializing object's __trunc__() method if the object doesn't implement __int__() or __index__(). > Note that PyNumber_Long() is now the only place inside the interpreter > calling the `nb_int` slot. But since it also has those undesirable code > paths accepting str and buffer-like objects, it's usable in fewer > situations than you'd expect. Maybe an alternate constructor could be added -- such as int.from_number() -- which would be restricted to calling __int__(), __index__(), and __trunc__(). _______________________________________________ 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/Q77PFIMCHDGB36LZTNMFG6NF7DE2UOSF/ Code of Conduct: http://python.org/psf/codeofconduct/