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-81313: Add the math.integer module (PEP-791) by serhiy-storchaka · Pull Request #133909 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented May 11, 2025 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Issue: PEP-791: Add a module for integer related math functions #81313

📚 Documentation preview 📚: https://cpython-previews--133909.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

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

efimov-mikhail reacted with hooray emoji
All reactions
  • 🎉 1 reaction
@serhiy-storchaka
pythongh-81313: Add the imath module
6e47acd
@serhiy-storchaka
serhiy-storchaka requested review from a team, corona10 and erlend-aasland as code owners May 11, 2025 20:37
@bedevere-app bedevere-app Bot mentioned this pull request May 11, 2025
PEP-791: Add a module for integer related math functions #81313
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label May 11, 2025
@serhiy-storchaka
Fix Sphinx warning.
62cb235
@serhiy-storchaka

serhiy-storchaka commented May 11, 2025

Copy link
Copy Markdown
Member Author

This is a further development of #13741.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented May 11, 2025

Copy link
Copy Markdown
Member

A PEP is being written for this module: skirpichev/peps#8

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

This comment was marked as resolved.

Sign in to view
itamaro

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

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

skirpichev

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

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

skirpichev
skirpichev reviewed May 12, 2025
View reviewed changes
Comment thread Doc/library/imath.rst Resolved

Uh oh!

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

@corona10

This comment was marked as resolved.

Sign in to view
@serhiy-storchaka
Support multiple interpreters.
091dab6
@skirpichev

This comment was marked as resolved.

Sign in to view
serhiy-storchaka added 4 commits May 12, 2025 09:55
@serhiy-storchaka
_PyLong_NumBits returns int64_t now.
71d7f4f
@serhiy-storchaka
Fix build on Windows.
7b61c5e
@serhiy-storchaka
Add in a toctree.
eaea554
@serhiy-storchaka
Regen generated files.
da3ceab
@skirpichev
skirpichev self-requested a review May 13, 2025 12:39
@skirpichev

This comment was marked as resolved.

Sign in to view
serhiy-storchaka added 4 commits June 1, 2025 09:17
@serhiy-storchaka
Merge branch 'main' into imath3
2ab90a5
@serhiy-storchaka
imath -> intmath
3299bf7
@serhiy-storchaka
Remove ilog2().
9b6a151
@serhiy-storchaka
Remove unneeded import.
7b327ec
@skirpichev skirpichev changed the title gh-81313: Add the imath module gh-81313: Add the intmath module Jun 1, 2025
@picnixz picnixz changed the title gh-81313: Add the intmath module gh-81313: Add the intmath module (PEP-791) Jun 1, 2025
skirpichev
skirpichev reviewed Jun 1, 2025
View reviewed changes
Comment thread Doc/library/intmath.rst Resolved

Uh oh!

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

Comment thread Doc/library/intmath.rst Resolved

Uh oh!

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

Comment thread Doc/library/intmath.rst Resolved

Uh oh!

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

Comment thread Doc/library/math.integer.rst Resolved

Uh oh!

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

Comment thread Doc/library/intmath.rst Resolved

Uh oh!

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

Comment thread Doc/library/intmath.rst Resolved

Uh oh!

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

Comment thread Doc/library/intmath.rst Resolved

Uh oh!

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

Comment thread Modules/intmathmodule.c Resolved

Uh oh!

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

Comment thread Modules/intmathmodule.c Resolved

Uh oh!

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

Comment thread Modules/intmathmodule.c Resolved

Uh oh!

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

@serhiy-storchaka @skirpichev
Apply suggestions from code review
3194384
Co-authored-by: Sergey B Kirpichev <[email protected]>
@serhiy-storchaka
Merge branch 'main' into imath3
3b7bd99
@skirpichev
skirpichev dismissed their stale review October 29, 2025 08:03

stale

@serhiy-storchaka
Fix the module name.
a5bac9c
@bedevere-app bedevere-app Bot added awaiting review and removed awaiting core review labels Oct 29, 2025
@serhiy-storchaka
Rewrite the math module documentation.
4425774
@serhiy-storchaka

serhiy-storchaka commented Oct 29, 2025

Copy link
Copy Markdown
Member Author

I used other way to fix the module name. This is a temporary hack, I hope we will make it a straight way in future.

All reactions

Sorry, something went wrong.

Uh oh!

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

@skirpichev

skirpichev commented Oct 29, 2025

Copy link
Copy Markdown
Member

I think test failures are relevant.

All reactions

Sorry, something went wrong.

Uh oh!

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

@serhiy-storchaka
Fix test_capi on macOS.
21791cd
@serhiy-storchaka
serhiy-storchaka requested a review from markshannon as a code owner October 29, 2025 11:14
vstinner
vstinner reviewed Oct 29, 2025
View reviewed changes
Comment thread Misc/NEWS.d/next/Library/2019-06-02-13-56-16.gh-issue-81313.axawSH.rst Resolved

Uh oh!

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

Comment thread Doc/whatsnew/3.15.rst Resolved

Uh oh!

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

@vstinner

vstinner commented Oct 29, 2025

Copy link
Copy Markdown
Member

@vstinner, I worked on this several days ago, and here is the result. But there is a flaw in this implementation -- math.integer.name is not 'math.integer', and the module attribute of its functions is not 'math.integer'. This affects pickling and the help output.

IMO it's good enough for a first iteration, we will have enough time until Python 3.15 final to find a way to fix these issues.

All reactions

Sorry, something went wrong.

Uh oh!

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

@serhiy-storchaka @vstinner
Update Misc/NEWS.d/next/Library/2019-06-02-13-56-16.gh-issue-81313.ax…
835a46c
…awSH.rst

Co-authored-by: Victor Stinner <[email protected]>
skirpichev
skirpichev reviewed Oct 30, 2025
View reviewed changes

@skirpichev skirpichev 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.

Playing with the new module, I found also this:

>>> math.integer.__spec__
ModuleSpec(name='_math_integer', loader=<_frozen_importlib_external.ExtensionFileLoader object at 0x7fdbdae6f150>, origin='/home/sk/src/cpython/build/lib.linux-x86_64-3.15/_math_integer.cpython-315-x86_64-linux-gnu.so')

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/library/math.integer.rst Resolved

Uh oh!

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

Comment thread Doc/library/math.integer.rst Resolved

Uh oh!

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

Comment thread Doc/library/math.rst
Comment on lines +723 to +724
For backward compatibility, the :mod:`math` module provides also aliases of
the following functions from the :mod:`math.integer` module:

@skirpichev skirpichev Oct 29, 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.

Please mention there, that these aliases are soft-deprecated.

BTW, why this section was moved?

Sorry, something went wrong.

Uh oh!

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

All reactions

@serhiy-storchaka serhiy-storchaka Oct 31, 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.

Because it is less important than other sections.

Sorry, something went wrong.

Uh oh!

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

All reactions

@skirpichev skirpichev Oct 31, 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 it is, if we want to communicate users this renaming. Though, it's important only for those who read docs in order... Up to you.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Modules/mathintegermodule.c
Comment on lines +1242 to +1244
/* Fix the __name__ attribute of the module and the __module__ attribute
* of its functions.
*/

@skirpichev skirpichev Oct 30, 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.

Could you, please, create an issue to track this?

IIUIC, currently it's also not clear how to name the module file (math_integermodule.c, math/integermodule.c or even intmathmodule.c). I.e. we should extend current naming scheme to submodules.

Sorry, something went wrong.

Uh oh!

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

All reactions

@serhiy-storchaka serhiy-storchaka Oct 31, 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.

See #140824.

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
skirpichev
skirpichev reviewed Oct 30, 2025
View reviewed changes
Comment thread Doc/library/math.integer.rst Resolved

Uh oh!

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

Comment thread Doc/library/math.integer.rst Resolved

Uh oh!

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

Comment thread Doc/library/math.integer.rst Resolved

Uh oh!

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

Comment thread Doc/library/math.integer.rst Resolved

Uh oh!

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

serhiy-storchaka and others added 2 commits October 31, 2025 11:08
@serhiy-storchaka @skirpichev
Apply suggestions from code review
5599504
Co-authored-by: Sergey B Kirpichev <[email protected]>
@serhiy-storchaka
soft deprecated
f7a06e5
skirpichev
skirpichev approved these changes Oct 31, 2025
View reviewed changes

@skirpichev skirpichev 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.

LGTM, with few nitpicks (up to Serhiy) and note about ModuleSpec(). (I suspect this might affect something.)

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 core review and removed awaiting review labels Oct 31, 2025
@serhiy-storchaka
Move the nbsp definition.
badeb5c
vstinner
vstinner approved these changes Oct 31, 2025
View reviewed changes

@vstinner vstinner 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.

LGTM

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/library/math.rst
.. versionchanged:: 3.10
Floats with integral values (like ``5.0``) are no longer accepted in the
:func:`factorial` function.

@vstinner vstinner Oct 31, 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 add a versionchanged to mention that these functions became aliases to math.integer functions?

Sorry, something went wrong.

Uh oh!

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

All reactions

@serhiy-storchaka serhiy-storchaka Oct 31, 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.

This did not change their behavior.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Doc/library/math.rst
Floats with integral values (like ``5.0``) are no longer accepted in the
:func:`factorial` function.


@vstinner vstinner Oct 31, 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.

You should add .. deprecated:: 3.15 to repeat that these functions are soft deprecated and math.integer functions should be used instead.

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 merge and removed awaiting core review labels Oct 31, 2025
@serhiy-storchaka
Update documentation.
0f385a5
@serhiy-storchaka
serhiy-storchaka merged commit dcf3cc5 into python:main Oct 31, 2025
4 checks passed

Uh oh!

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

@bedevere-app bedevere-app Bot removed the awaiting merge label Oct 31, 2025
@serhiy-storchaka
serhiy-storchaka deleted the imath3 branch October 31, 2025 14:13
@jjhelmus jjhelmus mentioned this pull request Nov 19, 2025
Update to CPython 3.15.0a2 astral-sh/python-build-standalone#860
Merged
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
@serhiy-storchaka @StanFromIreland
pythongh-81313: Add the math.integer module (PEP-791) (pythonGH-133909)
127dbb5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@hugovk hugovk hugovk left review comments
@picnixz picnixz picnixz left review comments
@vstinner vstinner vstinner approved these changes
@skirpichev skirpichev skirpichev approved these changes
@itamaro itamaro itamaro left review comments
@erlend-aasland erlend-aasland Awaiting requested review from erlend-aasland erlend-aasland is a code owner
@corona10 corona10 Awaiting requested review from corona10 corona10 is a code owner
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
@emmatyping emmatyping Awaiting requested review from emmatyping emmatyping is a code owner
@brettcannon brettcannon Awaiting requested review from brettcannon brettcannon is a code owner
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@ncoghlan ncoghlan Awaiting requested review from ncoghlan ncoghlan is a code owner
@warsaw warsaw Awaiting requested review from warsaw warsaw is a code owner
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

None yet

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.

7 participants

@serhiy-storchaka @vstinner @corona10 @skirpichev @itamaro @hugovk @picnixz
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.