Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions peps/pep-0791.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
PEP: 791
Title: math.integer --- submodule for integer-specific mathematics functions
Author: Sergey B Kirpichev <skirpichev@gmail.com>
Author: Neil Girdhar <misterhsheik@gmail.com>,
Sergey B Kirpichev <skirpichev@gmail.com>,
Tim Peters <tim.peters@gmail.com>,
Serhiy Storchaka <storchaka@gmail.com>
Sponsor: Victor Stinner <vstinner@python.org>
Discussions-To: https://discuss.python.org/t/92548
Status: Draft
Status: Accepted
Type: Standards Track
Created: 12-May-2025
Python-Version: 3.15
Post-History: `12-Jul-2018 <https://mail.python.org/archives/list/python-ideas@python.org/thread/YYJ5YJBJNCVXQWK5K3WSVNMPUSV56LOR/>`__,
`09-May-2025 <https://discuss.python.org/t/91337>`__,
`19-May-2025 <https://discuss.python.org/t/92548>`__,
Resolution: `23-Oct-2025 <https://discuss.python.org/t/92548/154>`__


Abstract
Expand Down Expand Up @@ -146,8 +150,8 @@ Module functions will accept integers and objects that implement the
object to an integer number. Suitable functions must be computed exactly,
given sufficient time and memory.

The :pypi:`intmath` package will provide new submodule content for older Python
versions.
The :pypi:`intmath` package, available on PyPI, will provide new submodule
content for older Python versions.


Possible Extensions
Expand All @@ -169,8 +173,8 @@ compatible interface for the stdlib.
Backwards Compatibility
=======================

As aliases in :external+py3.14:mod:`math` will be kept for an indefinite time
(their use would be discouraged), there are no anticipated code breaks.
As aliases in :external+py3.14:mod:`math` will be kept indefinitely (their use
would be discouraged), there are no anticipated code breaks.


How to Teach This
Expand Down Expand Up @@ -201,10 +205,11 @@ isqrt() renaming
---------------------------------------------

There was a brief discussion about exposing :external+py3.14:func:`math.isqrt`
as ``imath.sqrt`` in the same way that :external+py3.14:func:`cmath.sqrt` is
the complex version of :external+py3.14:func:`math.sqrt`. However, ``isqrt``
is ultimately a different function: it is the floor of the square root. It
would be confusing to give it the same name (under a different module).
as ``sqrt`` in the new namespace in the same way that
:external+py3.14:func:`cmath.sqrt` is the complex version of
:external+py3.14:func:`math.sqrt`. However, ``isqrt`` is ultimately a
different function: it is the floor of the square root. It would be confusing
to give it the same name (under a different submodule).


Module name
Expand All @@ -218,15 +223,15 @@ Other proposed names include ``ntheory`` (like SymPy's submodule),

But the SC prefers a submodule rather than a new top-level module. Most
popular variants of the :external+py3.14:mod:`math`'s submodule are:
``integer``, ``discrete`` or ``ntheory`` (author preference).
``integer``, ``discrete`` or ``ntheory``.


Acknowledgements
================

Thanks to Tim Peters for reviving the idea of splitting the
:external+py3.14:mod:`math` module. Thanks to Neil Girdhar for substantial
improvements of the initial draft.
Thanks to Victor Stinner for sponsoring this PEP.
Thanks to everyone who participated in the discussions on discuss.python.org,
providing feedback, especially to Oscar Benjamin, Steve Dower and Paul Moore.


Copyright
Expand Down