WebSafe 3.7github.com
|
|
🏠
Skip to content

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

Closed
skirpichev wants to merge 1 commit intopython:mainfrom
skirpichev:84978-as_float
Closed

gh-84978: expose __float__ dunder method as as_float#110460
skirpichev wants to merge 1 commit intopython:mainfrom
skirpichev:84978-as_float

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

1 participant

Comments