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

gh-89381: Fix signature for math.log and cmath.log by hauntsaninja · Pull Request #101115 · python/cpython · GitHub

Repository navigation

gh-89381: Fix signature for math.log and cmath.log - #101115

Closed
hauntsaninja wants to merge 2 commits into
python:mainfrom
hauntsaninja:gh-89381
Closed

hauntsaninja wants to merge 2 commits into
python:mainfrom
hauntsaninja:gh-89381

Conversation

hauntsaninja commented Jan 18, 2023 •
edited
Loading

Copy link
Copy Markdown
Contributor

The optional group in math.log seems unnecessary, as far as I can tell. Once we remove this, Argument Clinic knows what to do.

For cmath, we just do what math is already doing: use c_default = NULL (so the actual runtime logic is unchanged), but mark cmath.e as the fake default value.

The optional group in math.log seems unnecessary, as far as I can tell.
Once we remove this, Argument Clinic knows what to do.

For cmath, we just do what math is doing, which is use c_default = NULL
(so the actual runtime logic is unchanged), but mark cmath.e as the fake
default value.

Copy link
Copy Markdown
Member

Seems to be working. I'll keep #101070 in case someone will prefer base=None defaults. Now we got
something like this:

>>> inspect.signature(math.log)
<Signature (x, base=2.718281828459045, /)>

Maybe this is slightly cryptic: 1) magic constant appear, 2) there is an illusion that the special base=math.e works internally as log(x)/log(base). BTW, shouldn't be there regression tests (e.g. for the original issue with inspect.signature(cmath.log))?

Also, I think that docs for the math.log/cmath.log should be adapted. To me it was a surprise, that this requires a manual adjustment after fixing the docstring.

mdickinson self-requested a review January 19, 2023 16:28

Copy link
Copy Markdown
Member

Maybe this is slightly cryptic: 1) magic constant appear, 2) there is an illusion that the special base=math.e works internally as log(x)/log(base).

Agreed on both points; I prefer the solution in #101070.

Copy link
Copy Markdown
Member

@mdickinson, I can restore #101070, if you wish. But after #101123 I'm not sure that a broken signature is an issue for CPython.

Copy link
Copy Markdown
Member

@skirpichev The changes in #101070 look good to me, modulo one documentation suggestion (left in a comment). If you resurrect it, I'd be happy to merge it.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL