FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-102839: remove AC for math.log by skirpichev · Pull Request #102863 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .h  (1) .rst  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve performance of :func:`math.log` arguments handling by removing the argument clinic.
45 changes: 1 addition & 44 deletions Modules/clinic/mathmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 14 additions & 21 deletions Modules/mathmodule.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2284,33 +2284,22 @@ loghelper(PyObject* arg, double (*func)(double))
}


/*[clinic input]
math.log

x: object
[
base: object(c_default="NULL") = math.e
]
/

Return the logarithm of x to the given base.

If the base not specified, returns the natural logarithm (base e) of x.
[clinic start generated code]*/

/* AC: cannot convert yet, see gh-102839 and gh-89381, waiting
for support of multiple signatures */
static PyObject *
math_log_impl(PyObject *module, PyObject *x, int group_right_1,
PyObject *base)
/*[clinic end generated code: output=7b5a39e526b73fc9 input=0f62d5726cbfebbd]*/
math_log(PyObject *module, PyObject * const *args, Py_ssize_t nargs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can you please add a comment about why it is not converted to AC?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ok, I did.

{
PyObject *num, *den;
PyObject *ans;

num = loghelper(x, m_log);
if (num == NULL || base == NULL)
if (!_PyArg_CheckPositional("log", nargs, 1, 2))
return NULL;

num = loghelper(args[0], m_log);
if (num == NULL || nargs == 1)
return num;

den = loghelper(base, m_log);
den = loghelper(args[1], m_log);
if (den == NULL) {
Py_DECREF(num);
return NULL;
Expand All @@ -2322,6 +2311,10 @@ math_log_impl(PyObject *module, PyObject *x, int group_right_1,
return ans;
}

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

/*[clinic input]
math.log2
Expand Down Expand Up @@ -4045,7 +4038,7 @@ static PyMethodDef math_methods[] = {
{"lcm", _PyCFunction_CAST(math_lcm), METH_FASTCALL, math_lcm_doc},
MATH_LDEXP_METHODDEF
{"lgamma", math_lgamma, METH_O, math_lgamma_doc},
MATH_LOG_METHODDEF
{"log", _PyCFunction_CAST(math_log), METH_FASTCALL, math_log_doc},
{"log1p", math_log1p, METH_O, math_log1p_doc},
MATH_LOG10_METHODDEF
MATH_LOG2_METHODDEF
Expand Down

Back | FazBrowse Home | New Git URL