Skip to content
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

gh-84978: expose __float__ dunder method as as_float #110460

Closed
wants to merge 1 commit into from

Conversation

skirpichev
Copy link
Member

@skirpichev skirpichev commented Oct 6, 2023

This is a lightweight alternative for #26827 (an alternate constructor could be more discoverable option). Similar functions could be added for __complex__() and __int__() methods. But, probably, support of float subclasses in __float__() should be removed first (see #109311).

Of course, this is not an equivalent to PyFloat_AsDouble(), which tries to use __index__() dunder if there is no __float__() one. But maybe it could serve at least as a partial solution for the issue?


to decide:

  • name: as_float vs float (c.f. index)?


📚 Documentation preview 📚: https://cpython-previews--110460.org.readthedocs.build/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant