Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-101678: refactor the math module to use special functions from c11#101679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
miss-islington merged 13 commits intopython:mainfromskirpichev:math-c11
Feb 9, 2023

Conversation

@skirpichev
Copy link
Contributor

@skirpichevskirpichev commentedFeb 8, 2023
edited by miss-islington
Loading

Shouldn't affect users, hence no news.

Automerge-Triggered-By: GH:mdickinson

arhadthedev reacted with thumbs up emoji
@mdickinsonmdickinson added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelFeb 8, 2023
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@mdickinson for commit7d14105 🤖

If you want to schedule another build, you need to add the:hammer: test-with-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelFeb 8, 2023
@mdickinson
Copy link
Member

What's the benefit of doing this? The downside is that we potentially introduce a quality regression on some platforms.

@mdickinsonmdickinson self-requested a reviewFebruary 8, 2023 08:31
@skirpichev
Copy link
ContributorAuthor

skirpichev commentedFeb 8, 2023
edited
Loading

What's the benefit of doing this?

Less C code to maintain, perhaps?

BTW, for erf/erfc there are no failures so far.

we potentially introduce a quality regression on some platforms

It's not a for error functions, because platforms claims that they support C11 and libm's versions will play the game anyway ;) There is no such preprocessor flag as_I_M_A_BROKEN_LIBM_.

@mdickinsonmdickinson added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelFeb 8, 2023
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@mdickinson for commit468096b 🤖

If you want to schedule another build, you need to add the:hammer: test-with-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelFeb 8, 2023
@corona10
Copy link
Member

What's the benefit of doing this? The downside is that we potentially introduce a quality regression on some platforms.

If the patch satisfies C11 compiler requirement andPEP 11 support, it could be acceptable.

@mdickinson
Copy link
Member

mdickinson commentedFeb 8, 2023
edited
Loading

@corona10 Yes, the "this" in my comment could have been clearer.

So long as we keep this PR focused on removing what's now effectively dead code (the code that depends onHAVE_LOG2,HAVE_ERF, etc.not being defined), that's fine. It's the replacement of our owngamma andlgamma code that should be avoided - we'd be replacing tested, working code with code of unknown quality.

FWIW, speaking as the original author of thegamma andlgamma functions and maintainer of themath module, the maintenance burden from that code has been essentially zero since it was originally added.

@mdickinson
Copy link
Member

@skirpichev Thanks for the PR! I'll have time to review properly this evening (UTC+0).

@skirpichev
Copy link
ContributorAuthor

So long as we keep this PR focused on removing what's now effectively dead code

That was essentially the target of the issue.

Thank you for review and I'm sorry for a missed issue/pr (adding c11 keyword to search was too restrictive this time...)

@skirpichev
Copy link
ContributorAuthor

Maybe using math_1 wrapper for erf/erfc is more safe?

@mdickinson
Copy link
Member

Maybe using math_1 wrapper for erf/erfc is more safe?

I don't think it's needed, sinceerf anderfc can't overflow, and are valid over the entire real line.

Copy link
Member

@mdickinsonmdickinson left a comment

Choose a reason for hiding this comment

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

LGTM aside from two tiny nitpicks.

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
@skirpichev
Copy link
ContributorAuthor

skirpichev commentedFeb 9, 2023
edited
Loading

I don't think it's needed, since erf and erfc can't overflow, and are valid over the entire real line.

Same is true to the tanh, for example, isn't?

@skirpichev
Copy link
ContributorAuthor

skirpichev commentedFeb 9, 2023
edited
Loading

I would suggest merging math_1 and math_1_to_whatever (not used anywhere else). The comment before math_1_to_whatever does mention math_1 instead. Ditto for math_1_to_whatever. (One function call less, BTW)

@mdickinson, please review last two commits.

@mdickinson
Copy link
Member

I would suggest merging math_1 and math_1_to_whatever (not used anywhere else).

Sounds reasonable, but for ease of review let's have a separate PR for that, please! I'd like to get this one in, and that gets harder if the scope keeps changing.

@mdickinson
Copy link
Member

Same is true to the tanh, for example, isn't?

Very likely, yes. Note that that'snot a reason to changetanh as it currently is. The libm wrappers portion of the math module is highly stable, and we should be extremely conservative with changes.

@skirpichev
Copy link
ContributorAuthor

Sounds reasonable, but for ease of review let's have a separate PR for that

Ok, that part (47970e2) was reverted and I've fixed prefixes for gh issues.

arhadthedev reacted with thumbs up emoji

Copy link
Member

@mdickinsonmdickinson left a comment
edited
Loading

Choose a reason for hiding this comment

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

LGTM. I'll merge when CI completes.

@skirpichev
Copy link
ContributorAuthor

Note that that's not a reason to change tanh as it currently is.

Aside from some tiny performance bonus.

@miss-islington
Copy link
Contributor

Status check is done, and it's a success ✅.

@miss-islingtonmiss-islington merged commit5839575 intopython:mainFeb 9, 2023
@skirpichevskirpichev deleted the math-c11 branchFebruary 9, 2023 08:45
@mdickinson
Copy link
Member

Aargh. And now I remember (again) why I never use the auto-merge label - there's no opportunity to edit the final commit message. :-(

@skirpichev
Copy link
ContributorAuthor

Thanks for the hint. Next time I'll adjust pr title/body to follow review.

carljm added a commit to carljm/cpython that referenced this pull requestFeb 9, 2023
* main: (82 commits)pythongh-101670: typo fix in PyImport_ExtendInittab() (python#101723)pythonGH-99293: Document that `Py_TPFLAGS_VALID_VERSION_TAG` shouldn't be used. (#pythonGH-101736)  no-issue: Add Dong-hee Na as the cjkcodecs codeowner (pythongh-101731)pythongh-101678: Merge math_1_to_whatever() and math_1() (python#101730)pythongh-101678: refactor the math module to use special functions from c11 (pythonGH-101679)pythongh-85984: Remove legacy Lib/pty.py code. (python#92365)pythongh-98831: Use opcode metadata for stack_effect() (python#101704)pythongh-101283: Version was just released, so should be changed in 3.11.3 (pythonGH-101719)pythongh-101283: Fix use of unbound variable (pythonGH-101712)pythongh-101283: Improved fallback logic for subprocess with shell=True on Windows (pythonGH-101286)pythongh-101277: Port more itertools static types to heap types (python#101304)pythongh-98831: Modernize CALL and family (python#101508)pythonGH-101696: invalidate type version tag in `_PyStaticType_Dealloc` (python#101697)pythongh-100221: Fix creating dirs in `make sharedinstall` (pythonGH-100329)pythongh-101670: typo fix in PyImport_AppendInittab() (pythonGH-101672)pythongh-101196: Make isdir/isfile/exists faster on Windows (pythonGH-101324)pythongh-101614: Don't treat python3_d.dll as a Python DLL when checking extension modules for incompatibility (pythonGH-101615)pythongh-100933: Improve `check_element` helper in `test_xml_etree` (python#100934)pythonGH-101578: Normalize the current exception (pythonGH-101607)pythongh-47937: Note that Popen attributes are read-only (python#93070)  ...
@vstinner
Copy link
Member

Nice change.

Shouldn't affect users, hence no news.

In the past, I tried to document these "build changes", just in case if someone is affected. Like:

The C99 functions snprintf() and vsnprintf() are now required to build Python. (Contributed by Victor Stinner in bpo-36020.)

https://docs.python.org/dev/whatsnew/3.10.html#build-changes

@skirpichev
Copy link
ContributorAuthor

c11 compiler and stdlib (without optional features) were requiredsince 3.11, so there is nothing new in that sense.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@arhadthedevarhadthedevarhadthedev left review comments

+1 more reviewer

@mdickinsonmdickinsonmdickinson approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

extension-modulesC modules in the Modules dirskip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@skirpichev@bedevere-bot@mdickinson@corona10@miss-islington@vstinner@arhadthedev

[8]ページ先頭

©2009-2025 Movatter.jp