From 04a233ec2e4f5eec57f5b2bfa5576c2909fb6596 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Wed, 5 Nov 2025 05:53:00 +0300 Subject: [PATCH 1/3] gh-141004: deprecate Py_MATH_El and Py_MATH_PIl macros --- Doc/deprecations/c-api-pending-removal-in-3.20.rst | 2 ++ Doc/whatsnew/3.15.rst | 4 ++++ Include/pymath.h | 2 ++ .../next/C_API/2025-11-05-05-45-49.gh-issue-141004.N9Ooh9.rst | 1 + 4 files changed, 9 insertions(+) create mode 100644 Misc/NEWS.d/next/C_API/2025-11-05-05-45-49.gh-issue-141004.N9Ooh9.rst diff --git a/Doc/deprecations/c-api-pending-removal-in-3.20.rst b/Doc/deprecations/c-api-pending-removal-in-3.20.rst index 82f975d6ed4020..18623b19a2ab8d 100644 --- a/Doc/deprecations/c-api-pending-removal-in-3.20.rst +++ b/Doc/deprecations/c-api-pending-removal-in-3.20.rst @@ -5,3 +5,5 @@ Pending removal in Python 3.20 Use :c:func:`PyComplex_AsCComplex` and :c:func:`PyComplex_FromCComplex` to convert a Python complex number to/from the C :c:type:`Py_complex` representation. + +* Macros :c:macro:`!Py_MATH_PIl` and :c:macro:`!Py_MATH_El`. diff --git a/Doc/whatsnew/3.15.rst b/Doc/whatsnew/3.15.rst index 5379ac3abba227..8fa4334177e58d 100644 --- a/Doc/whatsnew/3.15.rst +++ b/Doc/whatsnew/3.15.rst @@ -1068,6 +1068,10 @@ Deprecated C APIs since 3.15 and will be removed in 3.17. (Contributed by Nikita Sobolev in :gh:`136355`.) +* :c:macro:`!Py_MATH_El` and :c:macro:`!Py_MATH_PIl` are deprecated + since 3.15 and will be removed in 3.20. + (Contributed by Sergey B Kirpichev in :gh:`141004`.) + .. Add C API deprecations above alphabetically, not here at the end. diff --git a/Include/pymath.h b/Include/pymath.h index e2919c7b527267..0f9f0f3b2990fe 100644 --- a/Include/pymath.h +++ b/Include/pymath.h @@ -7,6 +7,7 @@ /* High precision definition of pi and e (Euler) * The values are taken from libc6's math.h. */ +// Deprecated since Python 3.15. #ifndef Py_MATH_PIl #define Py_MATH_PIl 3.1415926535897932384626433832795029L #endif @@ -14,6 +15,7 @@ #define Py_MATH_PI 3.14159265358979323846 #endif +// Deprecated since Python 3.15. #ifndef Py_MATH_El #define Py_MATH_El 2.7182818284590452353602874713526625L #endif diff --git a/Misc/NEWS.d/next/C_API/2025-11-05-05-45-49.gh-issue-141004.N9Ooh9.rst b/Misc/NEWS.d/next/C_API/2025-11-05-05-45-49.gh-issue-141004.N9Ooh9.rst new file mode 100644 index 00000000000000..5f3ccd62016e11 --- /dev/null +++ b/Misc/NEWS.d/next/C_API/2025-11-05-05-45-49.gh-issue-141004.N9Ooh9.rst @@ -0,0 +1 @@ +:c:macro:`!Py_MATH_El` and :c:macro:`!Py_MATH_PIl` are deprecated. From d16bc4e9038155e4fbd6086a5d1feec6a1ceaf0a Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Wed, 5 Nov 2025 07:53:27 +0300 Subject: [PATCH 2/3] + docs --- Doc/c-api/float.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst index 489676caa3a16a..8aeef8cb6e8eeb 100644 --- a/Doc/c-api/float.rst +++ b/Doc/c-api/float.rst @@ -78,6 +78,20 @@ Floating-Point Objects Return the minimum normalized positive float *DBL_MIN* as C :c:expr:`double`. +.. c:macro:: Py_MATH_El + + Hight-precision (long double) definition of :data:`~math.e` constant. + + .. deprecated-removed:: 3.15 3.20 + + +.. c:macro:: Py_MATH_pil + + Hight-precision (long double) definition of :data:`~math.pi` constant. + + .. deprecated-removed:: 3.15 3.20 + + Pack and Unpack functions ------------------------- From fd0ebd8d321f8d2a88efe573b44a2f3f27443e10 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Wed, 5 Nov 2025 13:43:31 +0300 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Victor Stinner --- 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 8aeef8cb6e8eeb..7c2f652bc2f529 100644 --- a/Doc/c-api/float.rst +++ b/Doc/c-api/float.rst @@ -80,14 +80,14 @@ Floating-Point Objects .. c:macro:: Py_MATH_El - Hight-precision (long double) definition of :data:`~math.e` constant. + High precision (long double) definition of :data:`~math.e` constant. .. deprecated-removed:: 3.15 3.20 -.. c:macro:: Py_MATH_pil +.. c:macro:: Py_MATH_PIl - Hight-precision (long double) definition of :data:`~math.pi` constant. + High precision (long double) definition of :data:`~math.pi` constant. .. deprecated-removed:: 3.15 3.20