From d2a1cbe24323cd491d14a4e003b3c5955df4266e Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Fri, 14 Nov 2025 05:00:35 +0300 Subject: [PATCH 1/7] gh-141004: document Py_HUGE_VAL/IS_FINITE/IS_INFINITE/IS_NAN --- Doc/c-api/float.rst | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst index 79de5daaa90d8f..35cbe379b25ec8 100644 --- a/Doc/c-api/float.rst +++ b/Doc/c-api/float.rst @@ -99,6 +99,14 @@ Floating-Point Objects the C11 standard ```` header. +.. c:macro:: Py_HUGE_VAL + + Same as :c:macro:`Py_INFINITY`. + + .. deprecated:: 3.14 + The macro is soft deprecated. + + .. c:macro:: Py_MATH_E The definition (accurate for a :c:expr:`double` type) of the :data:`math.e` constant. @@ -147,6 +155,32 @@ Floating-Point Objects return PyFloat_FromDouble(copysign(INFINITY, sign)); +.. c:macro:: Py_IS_FINITE + + Determines if the given floating-point number has finite value i.e. it is + normal, subnormal or zero, but not infinite or NaN. + + .. deprecated:: 3.14 + The macro is soft deprecated. Use :c:macro:`!isfinite` instead. + + +.. c:macro:: Py_IS_INFINITE + + Determines if the given floating-point number arg is positive or negative + infinity. + + .. deprecated:: 3.14 + The macro is soft deprecated. Use :c:macro:`!isinf` instead. + + +.. c:macro:: Py_IS_NAN + + Determines if the given floating-point number is a not-a-number (NaN) value. + + .. deprecated:: 3.14 + The macro is soft deprecated. Use :c:macro:`!isnan` instead. + + Pack and Unpack functions ------------------------- From 202c27fd072130bce5ff654b32aa82dcf57081be Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Fri, 14 Nov 2025 05:03:22 +0300 Subject: [PATCH 2/7] +1 --- Doc/c-api/float.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst index 35cbe379b25ec8..748398e61e2987 100644 --- a/Doc/c-api/float.rst +++ b/Doc/c-api/float.rst @@ -166,7 +166,7 @@ Floating-Point Objects .. c:macro:: Py_IS_INFINITE - Determines if the given floating-point number arg is positive or negative + Determines if the given floating-point number is positive or negative infinity. .. deprecated:: 3.14 From b1d30c37a7df0ee15161546b9cffec073f78d6a9 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Fri, 14 Nov 2025 18:02:19 +0300 Subject: [PATCH 3/7] address review: Py_HUGE_VAL & :term:`soft deprecated` --- Doc/c-api/float.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst index 748398e61e2987..fac3c39c502663 100644 --- a/Doc/c-api/float.rst +++ b/Doc/c-api/float.rst @@ -87,7 +87,7 @@ Floating-Point Objects ```` header. .. deprecated:: 3.15 - The macro is soft deprecated. + The macro is :term:`soft deprecated`. .. c:macro:: Py_NAN @@ -101,10 +101,10 @@ Floating-Point Objects .. c:macro:: Py_HUGE_VAL - Same as :c:macro:`Py_INFINITY`. + Equivalent to :c:macro:`Py_INFINITY`. .. deprecated:: 3.14 - The macro is soft deprecated. + The macro is :term:`soft deprecated`. .. c:macro:: Py_MATH_E @@ -161,7 +161,7 @@ Floating-Point Objects normal, subnormal or zero, but not infinite or NaN. .. deprecated:: 3.14 - The macro is soft deprecated. Use :c:macro:`!isfinite` instead. + The macro is :term:`soft deprecated`. Use :c:macro:`!isfinite` instead. .. c:macro:: Py_IS_INFINITE @@ -170,7 +170,7 @@ Floating-Point Objects infinity. .. deprecated:: 3.14 - The macro is soft deprecated. Use :c:macro:`!isinf` instead. + The macro is :term:`soft deprecated`. Use :c:macro:`!isinf` instead. .. c:macro:: Py_IS_NAN @@ -178,7 +178,7 @@ Floating-Point Objects Determines if the given floating-point number is a not-a-number (NaN) value. .. deprecated:: 3.14 - The macro is soft deprecated. Use :c:macro:`!isnan` instead. + The macro is :term:`soft deprecated`. Use :c:macro:`!isnan` instead. Pack and Unpack functions From bb2bdcbf71b45a620ae4cda72135cead2d59a132 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Sat, 15 Nov 2025 02:09:48 +0300 Subject: [PATCH 4/7] Apply suggestions from code review Co-authored-by: Victor Stinner Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Doc/c-api/float.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst index fac3c39c502663..846ce697dd4fa2 100644 --- a/Doc/c-api/float.rst +++ b/Doc/c-api/float.rst @@ -101,7 +101,7 @@ Floating-Point Objects .. c:macro:: Py_HUGE_VAL - Equivalent to :c:macro:`Py_INFINITY`. + Equivalent to :c:macro:`!INFINITY`. .. deprecated:: 3.14 The macro is :term:`soft deprecated`. @@ -155,16 +155,16 @@ Floating-Point Objects return PyFloat_FromDouble(copysign(INFINITY, sign)); -.. c:macro:: Py_IS_FINITE +.. c:macro:: Py_IS_FINITE(X) - Determines if the given floating-point number has finite value i.e. it is - normal, subnormal or zero, but not infinite or NaN. + Determines if the given floating-point number has finite value, + that is, it is normal, subnormal or zero, but not infinite or NaN. .. deprecated:: 3.14 The macro is :term:`soft deprecated`. Use :c:macro:`!isfinite` instead. -.. c:macro:: Py_IS_INFINITE +.. c:macro:: Py_IS_INFINITY(X) Determines if the given floating-point number is positive or negative infinity. @@ -173,7 +173,7 @@ Floating-Point Objects The macro is :term:`soft deprecated`. Use :c:macro:`!isinf` instead. -.. c:macro:: Py_IS_NAN +.. c:macro:: Py_IS_NAN(X) Determines if the given floating-point number is a not-a-number (NaN) value. From 9d8f7b26096e5c5e07e2b7e84965f0814d983654 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Sat, 15 Nov 2025 02:13:24 +0300 Subject: [PATCH 5/7] Apply suggestions from code review --- Doc/c-api/float.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst index 846ce697dd4fa2..e2752c97b7b34c 100644 --- a/Doc/c-api/float.rst +++ b/Doc/c-api/float.rst @@ -157,7 +157,7 @@ Floating-Point Objects .. c:macro:: Py_IS_FINITE(X) - Determines if the given floating-point number has finite value, + Determines if the given floating-point number *X* has finite value, that is, it is normal, subnormal or zero, but not infinite or NaN. .. deprecated:: 3.14 @@ -166,7 +166,7 @@ Floating-Point Objects .. c:macro:: Py_IS_INFINITY(X) - Determines if the given floating-point number is positive or negative + Determines if the given floating-point number *X* is positive or negative infinity. .. deprecated:: 3.14 @@ -175,7 +175,7 @@ Floating-Point Objects .. c:macro:: Py_IS_NAN(X) - Determines if the given floating-point number is a not-a-number (NaN) value. + Determines if the given floating-point number *X* is a not-a-number (NaN) value. .. deprecated:: 3.14 The macro is :term:`soft deprecated`. Use :c:macro:`!isnan` instead. From 3c5edb530239afb7edce17f14ce609d351c07493 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Sun, 16 Nov 2025 03:14:12 +0300 Subject: [PATCH 6/7] Apply suggestions from code review Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Doc/c-api/float.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst index e2752c97b7b34c..3d153ed77577b7 100644 --- a/Doc/c-api/float.rst +++ b/Doc/c-api/float.rst @@ -157,8 +157,9 @@ Floating-Point Objects .. c:macro:: Py_IS_FINITE(X) - Determines if the given floating-point number *X* has finite value, - that is, it is normal, subnormal or zero, but not infinite or NaN. + Return ``1`` if the given floating-point number *X* is finite, + that is, it is normal, subnormal or zero, but not infinite or NaN; + else ``0``. .. deprecated:: 3.14 The macro is :term:`soft deprecated`. Use :c:macro:`!isfinite` instead. @@ -166,8 +167,8 @@ Floating-Point Objects .. c:macro:: Py_IS_INFINITY(X) - Determines if the given floating-point number *X* is positive or negative - infinity. + Return ``1`` if the given floating-point number *X* is positive or negative + infinity, else ``0``. .. deprecated:: 3.14 The macro is :term:`soft deprecated`. Use :c:macro:`!isinf` instead. @@ -175,7 +176,8 @@ Floating-Point Objects .. c:macro:: Py_IS_NAN(X) - Determines if the given floating-point number *X* is a not-a-number (NaN) value. + Return ``1`` if the given floating-point number *X* is a not-a-number (NaN) value, + else ``0``. .. deprecated:: 3.14 The macro is :term:`soft deprecated`. Use :c:macro:`!isnan` instead. From c225d02ef4209b94795f980f8d051df934228665 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 18 Nov 2025 02:05:25 +0300 Subject: [PATCH 7/7] address review: Return ``0`` otherwise. --- Doc/c-api/float.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst index 3d153ed77577b7..b0d440580b9886 100644 --- a/Doc/c-api/float.rst +++ b/Doc/c-api/float.rst @@ -158,8 +158,8 @@ Floating-Point Objects .. c:macro:: Py_IS_FINITE(X) Return ``1`` if the given floating-point number *X* is finite, - that is, it is normal, subnormal or zero, but not infinite or NaN; - else ``0``. + that is, it is normal, subnormal or zero, but not infinite or NaN. + Return ``0`` otherwise. .. deprecated:: 3.14 The macro is :term:`soft deprecated`. Use :c:macro:`!isfinite` instead. @@ -168,7 +168,7 @@ Floating-Point Objects .. c:macro:: Py_IS_INFINITY(X) Return ``1`` if the given floating-point number *X* is positive or negative - infinity, else ``0``. + infinity. Return ``0`` otherwise. .. deprecated:: 3.14 The macro is :term:`soft deprecated`. Use :c:macro:`!isinf` instead. @@ -176,8 +176,8 @@ Floating-Point Objects .. c:macro:: Py_IS_NAN(X) - Return ``1`` if the given floating-point number *X* is a not-a-number (NaN) value, - else ``0``. + Return ``1`` if the given floating-point number *X* is a not-a-number (NaN) + value. Return ``0`` otherwise. .. deprecated:: 3.14 The macro is :term:`soft deprecated`. Use :c:macro:`!isnan` instead.