Skip to content

gh-128813: soft-deprecate _Py_c_*() functions #137261

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

Merged
merged 1 commit into from
Aug 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Doc/c-api/complex.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,36 @@ pointers. This is consistent throughout the API.
Return the sum of two complex numbers, using the C :c:type:`Py_complex`
representation.

.. deprecated:: 3.15
This function is :term:`soft deprecated`.


.. c:function:: Py_complex _Py_c_diff(Py_complex left, Py_complex right)

Return the difference between two complex numbers, using the C
:c:type:`Py_complex` representation.

.. deprecated:: 3.15
This function is :term:`soft deprecated`.


.. c:function:: Py_complex _Py_c_neg(Py_complex num)

Return the negation of the complex number *num*, using the C
:c:type:`Py_complex` representation.

.. deprecated:: 3.15
This function is :term:`soft deprecated`.


.. c:function:: Py_complex _Py_c_prod(Py_complex left, Py_complex right)

Return the product of two complex numbers, using the C :c:type:`Py_complex`
representation.

.. deprecated:: 3.15
This function is :term:`soft deprecated`.


.. c:function:: Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor)

Expand All @@ -70,6 +82,9 @@ pointers. This is consistent throughout the API.
If *divisor* is null, this method returns zero and sets
:c:data:`errno` to :c:macro:`!EDOM`.

.. deprecated:: 3.15
This function is :term:`soft deprecated`.


.. c:function:: Py_complex _Py_c_pow(Py_complex num, Py_complex exp)

Expand All @@ -81,6 +96,19 @@ pointers. This is consistent throughout the API.

Set :c:data:`errno` to :c:macro:`!ERANGE` on overflows.

.. deprecated:: 3.15
This function is :term:`soft deprecated`.


.. c:function:: double _Py_c_abs(Py_complex num)

Return the absolute value of the complex number *num*.

Set :c:data:`errno` to :c:macro:`!ERANGE` on overflows.

.. deprecated:: 3.15
This function is :term:`soft deprecated`.


Complex Numbers as Python Objects
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
5 changes: 5 additions & 0 deletions Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,11 @@ Deprecated C APIs
signed integer type of the same size is now deprecated.
(Contributed by Serhiy Storchaka in :gh:`132629`.)

* Functions :c:func:`_Py_c_sum`, :c:func:`_Py_c_diff`, :c:func:`_Py_c_neg`,
:c:func:`_Py_c_prod`, :c:func:`_Py_c_quot`, :c:func:`_Py_c_pow` and
:c:func:`_Py_c_abs` are :term:`soft deprecated`.
(Contributed by Sergey B Kirpichev in :gh:`128813`.)

.. Add C API deprecations above alphabetically, not here at the end.

Removed C APIs
Expand Down
3 changes: 2 additions & 1 deletion Include/cpython/complexobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ typedef struct {
double imag;
} Py_complex;

// Operations on complex numbers.
/* Operations on complex numbers (soft deprecated
since Python 3.15). */
PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Functions :c:func:`_Py_c_sum`, :c:func:`_Py_c_diff`, :c:func:`_Py_c_neg`,
:c:func:`_Py_c_prod`, :c:func:`_Py_c_quot`, :c:func:`_Py_c_pow` and
previously undocumented :c:func:`_Py_c_abs` are :term:`soft deprecated`.
Patch by Sergey B Kirpichev.
Loading