FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-84978: expose __float__ dunder method as as_float by skirpichev · Pull Request #110460 · python/cpython · GitHub

/ cpython Public

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

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

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

Conversation

skirpichev commented Oct 6, 2023
edited
Loading

Copy link
Copy Markdown
Member

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/

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL