New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make int() fall back to trunc() #46286
Comments
Here's a patch to implement the fallback for both int and long. I'm |
Guido, are these basically the mechanics you intended? All calls to The logic looks basically correct, but I'm not sure what it buys us An alternative to this patch would be to have math.trunc() try to Either way will allow a user to define a __trunc__() method and have There is also part of this patch that touches classobject.c but I'm not |
All classic classes take the (m && m->nb_int) branch, so without the |
Yes, that's exactly what I suggested.
Unless it's already an int or long. I would expect a type that wants
Great -- so no penalty for builtin types.
Definitely not -- that would imply that math.trunc("42") would return
Correct, and that's as intended.
Looks like Jeffrey expained that already. |
Go for it. |
Submitted as r60566. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: