-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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-119613: deprecate Py_IS_NAN/INFINITY and Py_IS_FINITE #119701
gh-119613: deprecate Py_IS_NAN/INFINITY and Py_IS_FINITE #119701
Conversation
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Doc/whatsnew/3.14.rst
Outdated
@@ -193,6 +193,10 @@ Porting to Python 3.14 | |||
Deprecated | |||
---------- | |||
|
|||
* Deprecate ``Py_IS_NAN``, ``Py_IS_INFINITY`` and ``Py_IS_FINITE`` macros, | |||
use instead ``isnan``, ``isinf`` and ``isfinite`` available from ``<math.h>`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use instead ``isnan``, ``isinf`` and ``isfinite`` available from ``<math.h>`` | |
use instead :c:func:`!isnan`, :c:func:`!isinf` and :c:func:`!isfinite` available from :file:`math.h`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, these are usually macros, e.g.:
https://en.cppreference.com/w/c/numeric/math/isinf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure; but this is about the markup :)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to soft deprecate these macros, with a link to the glossary in thr What's New and Changelog entries (:term: syntax).
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. IMO a soft deprecation is enough. Keeping these macros around is not a major maintenance burden.
If PEP 743 is accepted, maybe we can provide a way to remove this function with an opt-in option.
Thanks for the updates @skirpichev, I enabled automerge. @skirpichev: If you are interested, there are other macros which might be worth it to soft deprecate such as Py_MEMCPY(). I removed this macro in the limited C API version 3.11: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
# define Py_MEMCPY memcpy
#endif |
@vstinner, we can deprecate also |
You can start by avoiding these macros in Python code base and see how it goes. Py_INFINITY and Py_NAN add a |
Hmm, from C11 Sec 7.2: "The macro INFINITY expands to a constant expression of type float representing positive or unsigned infinity, if available [...] The macro NAN is defined if and only if the implementation supports quiet NaNs for the float type. It expands to a constant expression of type float representing a quiet NaN." (c) As now build requirements include "Support for IEEE 754 floating point numbers and floating point Not-a-Number (NaN).", I think nowadays this type cast is useless. Yet, anyway, replacing (with a soft deprecation) Py_HUGE_VAL by Py_INFINITY - probably does make sense. I was mentioned in #104202 (comment). One obvious pro: current using both Py_HUGE_VAL and Py_INFINITY may confuse readers. |
📚 Documentation preview 📚: https://cpython-previews--119701.org.readthedocs.build/