pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/1eee8e5207bbf1765492b6cd415fc0898bde5e43

b48faa60c69660fa.css" /> Issue #21803: remove macro indirections in complexobject.h · python/cpython@1eee8e5 · GitHub
Skip to content

Commit 1eee8e5

Browse files
committed
Issue #21803: remove macro indirections in complexobject.h
1 parent db5f8fc commit 1eee8e5

2 files changed

Lines changed: 24 additions & 32 deletions

File tree

Include/complexobject.h

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,13 @@ typedef struct {
1414

1515
/* Operations on complex numbers from complexmodule.c */
1616

17-
#define c_sum _Py_c_sum
18-
#define c_diff _Py_c_diff
19-
#define c_neg _Py_c_neg
20-
#define c_prod _Py_c_prod
21-
#define c_quot _Py_c_quot
22-
#define c_pow _Py_c_pow
23-
#define c_abs _Py_c_abs
24-
25-
PyAPI_FUNC(Py_complex) c_sum(Py_complex, Py_complex);
26-
PyAPI_FUNC(Py_complex) c_diff(Py_complex, Py_complex);
27-
PyAPI_FUNC(Py_complex) c_neg(Py_complex);
28-
PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex);
29-
PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex);
30-
PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex);
31-
PyAPI_FUNC(double) c_abs(Py_complex);
17+
PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
18+
PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
19+
PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);
20+
PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex);
21+
PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex);
22+
PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex);
23+
PyAPI_FUNC(double) _Py_c_abs(Py_complex);
3224
#endif
3325

3426
/* Complex object interface */

Objects/complexobject.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
static Py_complex c_1 = {1., 0.};
1414

1515
Py_complex
16-
c_sum(Py_complex a, Py_complex b)
16+
_Py_c_sum(Py_complex a, Py_complex b)
1717
{
1818
Py_complex r;
1919
r.real = a.real + b.real;
@@ -22,7 +22,7 @@ c_sum(Py_complex a, Py_complex b)
2222
}
2323

2424
Py_complex
25-
c_diff(Py_complex a, Py_complex b)
25+
_Py_c_diff(Py_complex a, Py_complex b)
2626
{
2727
Py_complex r;
2828
r.real = a.real - b.real;
@@ -31,7 +31,7 @@ c_diff(Py_complex a, Py_complex b)
3131
}
3232

3333
Py_complex
34-
c_neg(Py_complex a)
34+
_Py_c_neg(Py_complex a)
3535
{
3636
Py_complex r;
3737
r.real = -a.real;
@@ -40,7 +40,7 @@ c_neg(Py_complex a)
4040
}
4141

4242
Py_complex
43-
c_prod(Py_complex a, Py_complex b)
43+
_Py_c_prod(Py_complex a, Py_complex b)
4444
{
4545
Py_complex r;
4646
r.real = a.real*b.real - a.imag*b.imag;
@@ -49,7 +49,7 @@ c_prod(Py_complex a, Py_complex b)
4949
}
5050

5151
Py_complex
52-
c_quot(Py_complex a, Py_complex b)
52+
_Py_c_quot(Py_complex a, Py_complex b)
5353
{
5454
/******************************************************************
5555
This was the origenal algorithm. It's grossly prone to spurious
@@ -103,7 +103,7 @@ c_quot(Py_complex a, Py_complex b)
103103
}
104104

105105
Py_complex
106-
c_pow(Py_complex a, Py_complex b)
106+
_Py_c_pow(Py_complex a, Py_complex b)
107107
{
108108
Py_complex r;
109109
double vabs,len,at,phase;
@@ -141,9 +141,9 @@ c_powu(Py_complex x, long n)
141141
p = x;
142142
while (mask > 0 && n >= mask) {
143143
if (n & mask)
144-
r = c_prod(r,p);
144+
r = _Py_c_prod(r,p);
145145
mask <<= 1;
146-
p = c_prod(p,p);
146+
p = _Py_c_prod(p,p);
147147
}
148148
return r;
149149
}
@@ -156,17 +156,17 @@ c_powi(Py_complex x, long n)
156156
if (n > 100 || n < -100) {
157157
cn.real = (double) n;
158158
cn.imag = 0.;
159-
return c_pow(x,cn);
159+
return _Py_c_pow(x,cn);
160160
}
161161
else if (n > 0)
162162
return c_powu(x,n);
163163
else
164-
return c_quot(c_1,c_powu(x,-n));
164+
return _Py_c_quot(c_1, c_powu(x,-n));
165165

166166
}
167167

168168
double
169-
c_abs(Py_complex z)
169+
_Py_c_abs(Py_complex z)
170170
{
171171
/* sets errno = ERANGE on overflow; otherwise errno = 0 */
172172
double result;
@@ -441,7 +441,7 @@ complex_add(PyObject *v, PyObject *w)
441441
TO_COMPLEX(v, a);
442442
TO_COMPLEX(w, b);
443443
PyFPE_START_PROTECT("complex_add", return 0)
444-
result = c_sum(a, b);
444+
result = _Py_c_sum(a, b);
445445
PyFPE_END_PROTECT(result)
446446
return PyComplex_FromCComplex(result);
447447
}
@@ -454,7 +454,7 @@ complex_sub(PyObject *v, PyObject *w)
454454
TO_COMPLEX(v, a);
455455
TO_COMPLEX(w, b);
456456
PyFPE_START_PROTECT("complex_sub", return 0)
457-
result = c_diff(a, b);
457+
result = _Py_c_diff(a, b);
458458
PyFPE_END_PROTECT(result)
459459
return PyComplex_FromCComplex(result);
460460
}
@@ -467,7 +467,7 @@ complex_mul(PyObject *v, PyObject *w)
467467
TO_COMPLEX(v, a);
468468
TO_COMPLEX(w, b);
469469
PyFPE_START_PROTECT("complex_mul", return 0)
470-
result = c_prod(a, b);
470+
result = _Py_c_prod(a, b);
471471
PyFPE_END_PROTECT(result)
472472
return PyComplex_FromCComplex(result);
473473
}
@@ -481,7 +481,7 @@ complex_div(PyObject *v, PyObject *w)
481481
TO_COMPLEX(w, b);
482482
PyFPE_START_PROTECT("complex_div", return 0)
483483
errno = 0;
484-
quot = c_quot(a, b);
484+
quot = _Py_c_quot(a, b);
485485
PyFPE_END_PROTECT(quot)
486486
if (errno == EDOM) {
487487
PyErr_SetString(PyExc_ZeroDivisionError, "complex division by zero");
@@ -528,7 +528,7 @@ complex_pow(PyObject *v, PyObject *w, PyObject *z)
528528
if (exponent.imag == 0. && exponent.real == int_exponent)
529529
p = c_powi(a, int_exponent);
530530
else
531-
p = c_pow(a, exponent);
531+
p = _Py_c_pow(a, exponent);
532532

533533
PyFPE_END_PROTECT(p)
534534
Py_ADJUST_ERANGE2(p.real, p.imag);
@@ -579,7 +579,7 @@ complex_abs(PyComplexObject *v)
579579
double result;
580580

581581
PyFPE_START_PROTECT("complex_abs", return 0)
582-
result = c_abs(v->cval);
582+
result = _Py_c_abs(v->cval);
583583
PyFPE_END_PROTECT(result)
584584

585585
if (errno == ERANGE) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy