8000 gh-102839: remove AC for math.log (GH-102863) · python/cpython@d1a89ce · GitHub
[go: up one dir, main page]

Skip to content

Commit d1a89ce

Browse files
authored
gh-102839: remove AC for math.log (GH-102863)
1 parent 41ef502 commit d1a89ce

File tree

3 files changed

+16
-65
lines changed

3 files changed

+16
-65
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve performance of :func:`math.log` arguments handling by removing the argument clinic.

Modules/clinic/mathmodule.c.h

Lines changed: 1 addition & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/mathmodule.c

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2284,33 +2284,22 @@ loghelper(PyObject* arg, double (*func)(double))
22842284
}
22852285

22862286

2287-
/*[clinic input]
2288-
math.log
2289-
2290-
x: object
2291-
[
2292-
base: object(c_default="NULL") = math.e
2293-
]
2294-
/
2295-
2296-
Return the logarithm of x to the given base.
2297-
2298-
If the base not specified, returns the natural logarithm (base e) of x.
2299-
[clinic start generated code]*/
2300-
2287+
/* AC: cannot convert yet, see gh-102839 and gh-89381, waiting
2288+
for support of multiple signatures */
23012289
static PyObject *
2302-
math_log_impl(PyObject *module, PyObject *x, int group_right_1,
2303-
PyObject *base)
2304-
/*[clinic end generated code: output=7b5a39e526b73fc9 input=0f62d5726cbfebbd]*/
2290+
math_log(PyObject *module, PyObject * const *args, Py_ssize_t nargs)
23052291
{
23062292
PyObject *num, *den;
23072293
PyObject *ans;
23082294

2309-
num = loghelper(x, m_log);
2310-
if (num == NULL || base == NULL)
2295+
if (!_PyArg_CheckPositional("log", nargs, 1, 2))
2296+
return NULL;
2297+
2298+
num = loghelper(args[0], m_log);
2299+
if (num == NULL || nargs == 1)
23112300
return num;
23122301

2313-
den = loghelper(base, m_log);
2302+
den = loghelper(args[1], m_log);
23142303
if (den == NULL) {
23152304
Py_DECREF(num);
23162305
return NULL;
@@ -2322,6 +2311,10 @@ math_log_impl(PyObject *module, PyObject *x, int group_right_1,
23222311
return ans;
23232312
}
23242313

2314+
PyDoc_STRVAR(math_log_doc,
2315+
"log(x, [base=math.e])\n\
2316+
Return the logarithm of x to the given base.\n\n\
2317+
If the base not specified, returns the natural logarithm (base e) of x.");
23252318

23262319
/*[clinic input]
23272320
math.log2
@@ -4045,7 +4038,7 @@ static PyMethodDef math_methods[] = {
40454038
{"lcm", _PyCFunction_CAST(math_lcm), METH_FASTCALL, math_lcm_doc},
40464039
MATH_LDEXP_METHODDEF
40474040
{"lgamma", math_lgamma, METH_O, math_lgamma_doc},
4048-
MATH_LOG_METHODDEF
4041+
{"log", _PyCFunction_CAST(math_log), METH_FASTCALL, math_log_doc},
40494042
{"log1p", math_log1p, METH_O, math_log1p_doc},
40504043
MATH_LOG10_METHODDEF
40514044
MATH_LOG2_METHODDEF

0 commit comments

Comments
 (0)
0