| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Macro docs should generally include the expansion (perhaps simplified). |
Sorry, something went wrong.
|
Unfortunately, that's a little tricky here, because the definition involves Py_NAN and Py_INFINITY, which aren't documented either (and probably things we should make private). Take a look at something like Py_RETURN_NONE for precedent. I think this is clear and fine for users. |
Sorry, something went wrong.
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 Py_NAN & Py_INFINITY being fully public, documented as primitive values of Python's math.nan and math.inf, and (equivalently) cross-platform versions of C99's NAN and INFINITY. |
Sorry, something went wrong.
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. |
Sorry, something went wrong.
|
Ok, I've updated it to include the macro expansion using C99's NAN and INFINITY. I'll adjust if we decide to make Py_NAN and Py_INFINITY public. |
Sorry, something went wrong.
|
Note that neither macro is used in the CPython codebase. Do we need them at all? Both return PyFloat_FromDouble(+/-INFINITY) or return PyFloat_FromDouble(NAN) are readable enough. |
Sorry, something went wrong.
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Is it used in any third parties? (We should document the macro nonetheless, but perhaps we could deprecate it.) |
Sorry, something went wrong.
It seems so, I see few matches in the Github search. Though, nothing that can't be replaced by something like return PyFloat_FromDouble(INFINITY*sign);, ditto for Py_RETURN_NAN. I think at least soft deprecation does make sense. |
Sorry, something went wrong.
|
If there's actual usage, I don't see why we need to deprecate these at all. They don't pose a maintenance issue. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
Thanks @ZeroIntensity for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
Sorry, something went wrong.
…GH-141029) (cherry picked from commit 5b02c6e) Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
|
GH-141074 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
…GH-141029) (cherry picked from commit 5b02c6e) Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
|
GH-141075 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
…GH-141029) Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
| Back | FazBrowse Home | New Git URL |
📚 Documentation preview 📚: https://cpython-previews--141029.org.readthedocs.build/en/141029/c-api/float.html#c.Py_RETURN_NAN