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

gh-81313: Add the math.integer module (PEP-791) by serhiy-storchaka · Pull Request #133909 · python/cpython · GitHub

Repository navigation

gh-81313: Add the math.integer module (PEP-791) - #133909

Merged
serhiy-storchaka merged 30 commits into
python:mainfrom
serhiy-storchaka:imath3
Oct 31, 2025
Merged

serhiy-storchaka merged 30 commits into
python:mainfrom
serhiy-storchaka:imath3

Conversation

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

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member Author

This is a further development of #13741.

Copy link
Copy Markdown
Member

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

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

Comment thread Doc/library/imath.rst

This comment was marked as resolved.

This comment was marked as resolved.

skirpichev self-requested a review May 13, 2025 12:39

This comment was marked as resolved.

skirpichev changed the title gh-81313: Add the imath module gh-81313: Add the intmath module Jun 1, 2025
picnixz changed the title gh-81313: Add the intmath module gh-81313: Add the intmath module (PEP-791) Jun 1, 2025
Comment thread Doc/library/intmath.rst Outdated
Comment thread Doc/library/intmath.rst Outdated
Comment thread Doc/library/intmath.rst Outdated
Comment thread Doc/library/math.integer.rst Outdated
Comment thread Doc/library/intmath.rst Outdated
Comment thread Doc/library/intmath.rst Outdated
Comment thread Doc/library/intmath.rst Outdated
Comment thread Modules/intmathmodule.c Outdated
Comment thread Modules/intmathmodule.c Outdated
Comment thread Modules/intmathmodule.c Outdated
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>

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.

Copy link
Copy Markdown
Member

I think test failures are relevant.

Comment thread Doc/whatsnew/3.15.rst

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.

…awSH.rst

Co-authored-by: Victor Stinner <vstinner@python.org>

skirpichev left a comment

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

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')

Comment thread Doc/library/math.integer.rst Outdated
Comment thread Doc/library/math.integer.rst Outdated
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:

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

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

BTW, why this section was moved?

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

Because it is less important than other sections.

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

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.

Comment on lines +1242 to +1244
/* Fix the __name__ attribute of the module and the __module__ attribute
* of its functions.
*/

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

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.

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

See #140824.

Comment thread Doc/library/math.integer.rst Outdated
Comment thread Doc/library/math.integer.rst Outdated
Comment thread Doc/library/math.integer.rst Outdated
Comment thread Doc/library/math.integer.rst Outdated
serhiy-storchaka and others added 2 commits October 31, 2025 11:08
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>

skirpichev left a comment

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

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

vstinner left a comment

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

LGTM

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.

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

Maybe add a versionchanged to mention that these functions became aliases to math.integer functions?

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

This did not change their behavior.

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


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

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

serhiy-storchaka merged commit dcf3cc5 into python:main Oct 31, 2025
54 checks passed
serhiy-storchaka deleted the imath3 branch October 31, 2025 14:13
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants


Back | FazBrowse Home | New Git URL