Skip to content

gh-81313: Add the intmath module (PEP-791) #133909

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented May 11, 2025

@serhiy-storchaka
Copy link
Member Author

This is a further development of #13741.

@vstinner
Copy link
Member

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

@vstinner

This comment was marked as resolved.

itamaro

This comment was marked as resolved.

skirpichev

This comment was marked as resolved.

Comment on lines 12 to 13
These functions accept integers and objects that implement the
:meth:`~object.__index__` method which is used to convert the object to an integer
Copy link
Contributor

Choose a reason for hiding this comment

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

In the same way we could simplify now description of argument processing in the math module. Except for a special snowflake "log" - all use PyFloat_AsDouble(). (Well, few functions also try special dunder methods.)

Though, probably it's for following prs.

@corona10

This comment was marked as resolved.

@skirpichev

This comment was marked as resolved.

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

This comment was marked as resolved.

@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
Comment on lines +14 to +15
number. They cannot be used with floating-point numbers or complex
numbers.
Copy link
Contributor

Choose a reason for hiding this comment

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

Last sentence looks redundant, though maybe it worth to be here.

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
expression (1 + x)**n.

Raises ValueError if either of the arguments are negative.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

Return factorial of the nonnegative integer *n*.


.. function:: gcd(a, b)
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it gcd(*integers)?

Return factorial of the nonnegative integer *n*.


.. function:: gcd(a, b)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.. function:: gcd(a, b)
.. function:: gcd(*integers)

@@ -83,7 +83,11 @@ Other language changes
New modules
===========

* None yet.
intmath
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add an entry under the PEP-sized items as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not all PEP's mentioned in release Summary (e.g. PEP 757 for the 3.13).

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but for 3.14, I think we're mentioning them all? @hugovk do you want to mention the PEP? Or at least, we should have a link to the PEP. There is none at the moment (annotationlib got one)

Copy link
Member

Choose a reason for hiding this comment

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

Ask me after the PEP has been accepted :)

Comment on lines +89 to +90
This module provides access to the mathematical functions for integer arguments.
(Contributed by Serhiy Storchaka in :gh:`81313`.)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This module provides access to the mathematical functions for integer arguments.
(Contributed by Serhiy Storchaka in :gh:`81313`.)
This module provides access to the mathematical functions for integer
arguments (:pep:`791`).
(Contributed by Serhiy Storchaka in :gh:`81313`.)

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.

7 participants