GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-140824: Implement the math package in Python by vstinner · Pull Request #141363 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Nov 10, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Rename the 'math' extension to '_math'.

  • Issue: Make the math module an extension package #140824

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
pythongh-140824: Implement the math package in Python
9f5cc45
Rename the 'math' extension to '_math'.
@vstinner
vstinner requested review from AA-Turner, corona10, emmatyping and erlend-aasland as code owners November 10, 2025 16:11
@vstinner vstinner added the skip news label Nov 10, 2025
@bedevere-app bedevere-app Bot added the awaiting core review label Nov 10, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Nov 10, 2025
Make the math module an extension package #140824
Open
vstinner added 2 commits November 10, 2025 17:12
@vstinner
Remove _math_integer exec code
f2650f7
@vstinner
test_math: add MiscTests
a6430dc
AA-Turner
AA-Turner requested changes Nov 10, 2025
View reviewed changes
Comment thread Modules/Setup Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/Setup.stdlib.in Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread configure.ac Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/math/__init__.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/math/__init__.py
Comment on lines +7 to +8
# gh-140824: Fix module name for pickle
def patch_module(objs, module):

@AA-Turner AA-Turner Nov 10, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Would it be better just to have the module name as math.integer for these functions in C?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Nov 10, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

In C, function.__module__ is set to the extension name: so set to _math or _math_integer. The whole purpose of this PR is to fix function.__module__.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting changes and removed awaiting core review labels Nov 10, 2025
@bedevere-app

bedevere-app Bot commented Nov 10, 2025

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
Fix build on Windows
f510afd
@vstinner
vstinner requested a review from a team as a code owner November 10, 2025 16:16
AA-Turner
AA-Turner reviewed Nov 10, 2025
View reviewed changes
Comment thread Lib/test/test_math.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

vstinner and others added 4 commits November 10, 2025 17:19
@vstinner
Sort lists
2d2afd6
@vstinner
Fix math.integer docstring
d60e832
@vstinner
Fix math docstring
7cf0fc1
@vstinner @AA-Turner
Update Lib/test/test_math.py
a20e9fb
Co-authored-by: Adam Turner <[email protected]>
@vstinner

vstinner commented Nov 10, 2025

Copy link
Copy Markdown
Member Author

@AA-Turner: I addressed your review. Please review the updated PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
Run make regen-configure
2527857
serhiy-storchaka
serhiy-storchaka reviewed Nov 10, 2025
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This is still a hack. I think there should be more straightforward way.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

skirpichev reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@vstinner
Run make regen-stdlib-module-names
aaeaee1
AA-Turner
AA-Turner reviewed Nov 10, 2025
View reviewed changes
Comment thread Lib/math/__init__.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@vstinner
Fix again the math docstring
d366724
@sergey-miryanov sergey-miryanov mentioned this pull request Nov 10, 2025
Segfault in faulthandler signal handler with threads #116008
Closed
@vstinner
Makefile.pre.in: update LIBSUBDIRS
49e6b3a
@skirpichev
skirpichev self-requested a review November 10, 2025 22:35
skirpichev
skirpichev reviewed Nov 20, 2025
View reviewed changes
Comment thread Lib/math/__init__.py
Comment on lines +17 to +18
from _math_integer import comb, factorial, gcd, isqrt, lcm, perm
patch_module([comb, factorial, gcd, isqrt, lcm, perm], 'math.integer')

@skirpichev skirpichev Nov 20, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Maybe then instead:

import _math_integer
patch_module(_math_integer, 'math.integer')

where in the patch_module() you will fix all public names in the submodule namespace?

This still be a hack, but at least we can factor out patch_module() to some helper function, that can be used when a new submodule will be added to the stdlib.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka

serhiy-storchaka commented Nov 20, 2025

Copy link
Copy Markdown
Member

I believe there is a way to do this without hacks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jan 22, 2026

Copy link
Copy Markdown
Member Author

@serhiy-storchaka dislikes this approach, so I prefer to close my PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner closed this Jan 22, 2026
@vstinner
vstinner deleted the _math branch January 22, 2026 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@skirpichev skirpichev skirpichev left review comments
@serhiy-storchaka serhiy-storchaka serhiy-storchaka left review comments
@AA-Turner AA-Turner AA-Turner requested changes
@erlend-aasland erlend-aasland Awaiting requested review from erlend-aasland erlend-aasland is a code owner
@emmatyping emmatyping Awaiting requested review from emmatyping emmatyping is a code owner
@corona10 corona10 Awaiting requested review from corona10 corona10 is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting changes skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@vstinner @serhiy-storchaka @skirpichev @AA-Turner
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.