Skip to content

Conversation

@skirpichev
Copy link
Contributor

@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