@@ -2284,33 +2284,22 @@ loghelper(PyObject* arg, double (*func)(double))
2284
2284
}
2285
2285
2286
2286
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 */
2301
2289
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 )
2305
2291
{
2306
2292
PyObject * num , * den ;
2307
2293
PyObject * ans ;
2308
2294
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 )
2311
2300
return num ;
2312
2301
2313
- den = loghelper (base , m_log );
2302
+ den = loghelper (args [ 1 ] , m_log );
2314
2303
if (den == NULL ) {
2315
2304
Py_DECREF (num );
2316
2305
return NULL ;
@@ -2322,6 +2311,10 @@ math_log_impl(PyObject *module, PyObject *x, int group_right_1,
2322
2311
return ans ;
2323
2312
}
2324
2313
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." );
2325
2318
2326
2319
/*[clinic input]
2327
2320
math.log2
@@ -4045,7 +4038,7 @@ static PyMethodDef math_methods[] = {
4045
4038
{"lcm" , _PyCFunction_CAST (math_lcm ), METH_FASTCALL , math_lcm_doc },
4046
4039
MATH_LDEXP_METHODDEF
4047
4040
{"lgamma" , math_lgamma , METH_O , math_lgamma_doc },
4048
- MATH_LOG_METHODDEF
4041
+ { "log" , _PyCFunction_CAST ( math_log ), METH_FASTCALL , math_log_doc },
4049
4042
{"log1p" , math_log1p , METH_O , math_log1p_doc },
4050
4043
MATH_LOG10_METHODDEF
4051
4044
MATH_LOG2_METHODDEF
0 commit comments