Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-141004: Document Py_RETURN_NAN and Py_RETURN_INF#141029
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-141004: Document Py_RETURN_NAN and Py_RETURN_INF#141029
Uh oh!
There was an error while loading. Please reload this page.
Conversation
ZeroIntensity commented Nov 4, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Py_RETURN_NAN and Py_RETURN_INFencukou commented Nov 4, 2025
Macro docs should generally include the expansion (perhaps simplified). |
ZeroIntensity commented Nov 4, 2025
Unfortunately, that's a little tricky here, because the definition involves Take a look at something like |
encukou commented Nov 4, 2025
I disagree there. I think it's clear as mud to someone who'd see it for the first time.
The expansion can be approximate -- it should illustrate the concept for to C programmers, and be a hint for the non-C ones (who generally can't use headers and need to reimplement macros). But I'd also be fine with |
skirpichev commented Nov 5, 2025
I agree, we shouldn't use pure-Python world equivalents.
See issue thread on fate of such macros. I hope we could reference to INFINITY/NAN from the C standard. |
ZeroIntensity commented Nov 5, 2025
Ok, I've updated it to include the macro expansion using C99's |
skirpichev commented Nov 5, 2025
Note that neither macro is used in the CPython codebase. Do we need them at all? Both |
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Sergey B Kirpichev <[email protected]>
ZeroIntensity commented Nov 5, 2025
Is it used in any third parties? (We should document the macro nonetheless, but perhaps we could deprecate it.) |
skirpichev commented Nov 5, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
It seems so, I see few matches in the Github search. Though, nothing that can't be replaced by something like |
ZeroIntensity commented Nov 5, 2025
If there's actual usage, I don't see why we need to deprecate these at all. They don't pose a maintenance issue. |
ZeroIntensity commented Nov 5, 2025
Ok, I'm going to merge this. @encukou, if you'd like to deprecate these, let's do that in a separate PR for 3.15 only. I personally don't see any need to deprecate them. |
5b02c6e into python:mainUh oh!
There was an error while loading. Please reload this page.
Thanks @ZeroIntensity for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…GH-141029) (cherry picked from commit 5b02c6e) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Sergey B Kirpichev <[email protected]>
GH-141074 is a backport of this pull request to the 3.14 branch. |
…GH-141029) (cherry picked from commit 5b02c6e) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Sergey B Kirpichev <[email protected]>
GH-141075 is a backport of this pull request to the 3.13 branch. |
…1029) (GH-141074) gh-141004: Document `Py_RETURN_NAN` and `Py_RETURN_INF` (GH-141029) (cherry picked from commit 5b02c6e) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Sergey B Kirpichev <[email protected]>
…1029) (GH-141075) gh-141004: Document `Py_RETURN_NAN` and `Py_RETURN_INF` (GH-141029) (cherry picked from commit 5b02c6e) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Sergey B Kirpichev <[email protected]>
…GH-141029) Co-authored-by: Sergey B Kirpichev <[email protected]>
📚 Documentation preview 📚: https://cpython-previews--141029.org.readthedocs.build/en/141029/c-api/float.html#c.Py_RETURN_NAN