Skip to content

Commit 0439323

Browse files
committed
gh-128813: hide mixed-mode functions for complex arithmetic from C-API
1 parent bc26f95 commit 0439323

File tree

4 files changed

+12
-60
lines changed

4 files changed

+12
-60
lines changed

Doc/c-api/complex.rst

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,12 @@ pointers. This is consistent throughout the API.
4444
representation.
4545
4646
47-
.. c:function:: Py_complex _Py_cr_sum(Py_complex left, double right)
48-
49-
Return the sum of a complex number and a real number, using the C :c:type:`Py_complex`
50-
representation.
51-
52-
.. versionadded:: 3.14
53-
54-
5547
.. c:function:: Py_complex _Py_c_diff(Py_complex left, Py_complex right)
5648
5749
Return the difference between two complex numbers, using the C
5850
:c:type:`Py_complex` representation.
5951
6052
61-
.. c:function:: Py_complex _Py_cr_diff(Py_complex left, double right)
62-
63-
Return the difference between a complex number and a real number, using the C
64-
:c:type:`Py_complex` representation.
65-
66-
.. versionadded:: 3.14
67-
68-
69-
.. c:function:: Py_complex _Py_rc_diff(double left, Py_complex right)
70-
71-
Return the difference between a real number and a complex number, using the C
72-
:c:type:`Py_complex` representation.
73-
74-
.. versionadded:: 3.14
75-
76-
7753
.. c:function:: Py_complex _Py_c_neg(Py_complex num)
7854
7955
Return the negation of the complex number *num*, using the C
@@ -86,14 +62,6 @@ pointers. This is consistent throughout the API.
8662
representation.
8763
8864
89-
.. c:function:: Py_complex _Py_cr_prod(Py_complex left, double right)
90-
91-
Return the product of a complex number and a real number, using the C
92-
:c:type:`Py_complex` representation.
93-
94-
.. versionadded:: 3.14
95-
96-
9765
.. c:function:: Py_complex _Py_c_quot(Py_complex dividend, Py_complex divisor)
9866
9967
Return the quotient of two complex numbers, using the C :c:type:`Py_complex`
@@ -103,28 +71,6 @@ pointers. This is consistent throughout the API.
10371
:c:data:`errno` to :c:macro:`!EDOM`.
10472
10573
106-
.. c:function:: Py_complex _Py_cr_quot(Py_complex dividend, double divisor)
107-
108-
Return the quotient of a complex number and a real number, using the C
109-
:c:type:`Py_complex` representation.
110-
111-
If *divisor* is zero, this method returns zero and sets
112-
:c:data:`errno` to :c:macro:`!EDOM`.
113-
114-
.. versionadded:: 3.14
115-
116-
117-
.. c:function:: Py_complex _Py_rc_quot(double dividend, Py_complex divisor)
118-
119-
Return the quotient of a real number and a complex number, using the C
120-
:c:type:`Py_complex` representation.
121-
122-
If *divisor* is zero, this method returns zero and sets
123-
:c:data:`errno` to :c:macro:`!EDOM`.
124-
125-
.. versionadded:: 3.14
126-
127-
12874
.. c:function:: Py_complex _Py_c_pow(Py_complex num, Py_complex exp)
12975
13076
Return the exponentiation of *num* by *exp*, using the C :c:type:`Py_complex`

Include/cpython/complexobject.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,10 @@ typedef struct {
99

1010
// Operations on complex numbers.
1111
PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
12-
PyAPI_FUNC(Py_complex) _Py_cr_sum(Py_complex, double);
1312
PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
14-
PyAPI_FUNC(Py_complex) _Py_cr_diff(Py_complex, double);
15-
PyAPI_FUNC(Py_complex) _Py_rc_diff(double, Py_complex);
1613
PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);
1714
PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex);
18-
PyAPI_FUNC(Py_complex) _Py_cr_prod(Py_complex, double);
1915
PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex);
20-
PyAPI_FUNC(Py_complex) _Py_cr_quot(Py_complex, double);
21-
PyAPI_FUNC(Py_complex) _Py_rc_quot(double, Py_complex);
2216
PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex);
2317
PyAPI_FUNC(double) _Py_c_abs(Py_complex);
2418

Include/internal/pycore_complexobject.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ extern int _PyComplex_FormatAdvancedWriter(
1919
Py_ssize_t start,
2020
Py_ssize_t end);
2121

22+
// Operations on complex numbers.
23+
PyAPI_FUNC(Py_complex) _Py_cr_sum(Py_complex, double);
24+
PyAPI_FUNC(Py_complex) _Py_cr_diff(Py_complex, double);
25+
PyAPI_FUNC(Py_complex) _Py_rc_diff(double, Py_complex);
26+
PyAPI_FUNC(Py_complex) _Py_cr_prod(Py_complex, double);
27+
PyAPI_FUNC(Py_complex) _Py_cr_quot(Py_complex, double);
28+
PyAPI_FUNC(Py_complex) _Py_rc_quot(double, Py_complex);
29+
30+
2231
#ifdef __cplusplus
2332
}
2433
#endif

Modules/_testcapi/complex.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#include "parts.h"
22
#include "util.h"
33

4+
#define Py_BUILD_CORE
5+
#include "pycore_complexobject.h"
6+
47

58
static PyObject *
69
complex_fromccomplex(PyObject *Py_UNUSED(module), PyObject *obj)

0 commit comments

Comments
 (0)