Draft PEP: imath --- module for number-theoretic functions#8
Draft PEP: imath --- module for number-theoretic functions#8skirpichev wants to merge 16 commits into
Conversation
|
|
||
| Unless we can just provide bindings to some well supported mathematical | ||
| library like the GMP, the module scope should be limited. For example, no | ||
| primality testing and factorization. |
There was a problem hiding this comment.
Thank you :-) IMO primality testing is a can a worm and a bad idea for the stdlib :-(
There was a problem hiding this comment.
That was just a first example coming in my mind.
I think it's a good idea to show some border line. For the math/cmath modules we have the C standard to reject new stuff. Here it's less obvious.
|
@NeilGirdhar, per Victor's opinion I'll prefer to defer major rewriting in #9. Some parts, on which it seems we agree - are ported. If you are ok with this - I'll add you as co-author and create a pr against the peps repo. Or add you to Acknowledgements section. |
|
I think the other one reads better (in terms of syntax and grammar, etc.) Since we agree on everything else, why don't we just get rid of the section you don't like in the other one and submit #9? |
| There is already an ``imath`` project on PyPI, but only with two releases, with | ||
| the most recent one 4 years ago. Its repository is no longer accessible. |
There was a problem hiding this comment.
the pypi project may be abandoned, but this Imath is maintained and fairly active.
Naive code search across my employer's repo has hundreds of hits referring to that imath.
could you consider going with a different name please? :)
There was a problem hiding this comment.
I appreciate options. Current version is a compromise, based on the poll. As you could see, I'm in a tiny camp of "something else". My initial proposal was "ntheory" (it also has a dead toy project on PyPI).
I would guess, that words like "random" or "fractions" have even more hits. BTW, linked project seems unrelated to the Python ecosystem.
There was a problem hiding this comment.
BTW, linked project seems unrelated to the Python ecosystem.
What do you mean by "unrelated"? It's a C++ library with Python bindings!
There was a problem hiding this comment.
Hmm, indeed. Though, as naming is still in the "Open Issues", I wouldn't care too much right now.
@vstinner, what do you think if we start from the "ntheory" variant?
|
@NeilGirdhar, I opened python#4422 It looks we fail to reach a consensus on #9, while sponsor seems ok with the current version. So I added you to "Thanks" section so far. |
|
I suppose that this PR can be closed since python#4422 was created. |
Could you at least fix all of the grammatical errors? |
Would you mind to write a review on python#4422 ? |
| Type: Standards Track | ||
| Created: 10-May-2025 | ||
| Python-Version: 3.15 | ||
| Post-History: 02-Jun-2019, |
There was a problem hiding this comment.
Is there no link to the thread?
| to the mathematical functions defined by the C standard." But as a state of | ||
| art, over time the module was populated with functions that aren't related to |
| The :external+py3.14:mod:`math` documentation says: "This module provides access | ||
| to the mathematical functions defined by the C standard." But as a state of | ||
| art, over time the module was populated with functions that aren't related to | ||
| the C standard or floating-point arithmetics. Now it's much harder to describe |
| module scope, content and interfaces (returned values or accepted arguments). | ||
|
|
||
| For example, the :external+py3.14:mod:`math` module documentation says: "Except | ||
| when explicitly noted otherwise, all return values are floats." This is not |
| For example, the :external+py3.14:mod:`math` module documentation says: "Except | ||
| when explicitly noted otherwise, all return values are floats." This is not | ||
| longer true: *None* of the functions listed in the "Number-theoretic | ||
| functions" [1]_ subsection of the documentation returns a float, but the |
| longer true: *None* of the functions listed in the "Number-theoretic | ||
| functions" [1]_ subsection of the documentation returns a float, but the | ||
| documentation doesn't say so. In the proposed module a similar sentence "All | ||
| return values are integers." could tell the truth once. In a similar way we |
There was a problem hiding this comment.
How about would consistently reflect reality. The current one is a bit awkward.
| functions" [1]_ subsection of the documentation returns a float, but the | ||
| documentation doesn't say so. In the proposed module a similar sentence "All | ||
| return values are integers." could tell the truth once. In a similar way we | ||
| can simplify description of accepted arguments for both the |
There was a problem hiding this comment.
simplify the description of accepted arguments
| can simplify description of accepted arguments for both the | ||
| :external+py3.14:mod:`math` and the new module. | ||
|
|
||
| Apparently, the :external+py3.14:mod:`math` can't serve as a catch-all place |
There was a problem hiding this comment.
the :external+py3.14:mod:math module can't serve
| :external+py3.14:mod:`math` and the new module. | ||
|
|
||
| Apparently, the :external+py3.14:mod:`math` can't serve as a catch-all place | ||
| for mathematical functions: we have also the :external+py3.14:mod:`cmath` and |
|
|
||
| Apparently, the :external+py3.14:mod:`math` can't serve as a catch-all place | ||
| for mathematical functions: we have also the :external+py3.14:mod:`cmath` and | ||
| the :external+py3.14:mod:`statistics`. Let's make same for integer-related |
| Specification | ||
| ============= | ||
|
|
||
| The PEP proposes moving the following integer-related functions [1]_ in a new |
There was a problem hiding this comment.
functions [1]_ to a new
Sorry I cannot do suggestions, the button is not there and otherwise this is more efficient.
|
|
||
| Their aliases in :external+py3.14:mod:`math` will be :term:`soft deprecated`. | ||
|
|
||
| Modules functions will accept integers and objects that implement the |
| :external+py3.14:meth:`~object.__index__` method which is used to convert the | ||
| object to an integer number. | ||
|
|
||
| Possible extensions for the new module and it's scope are discussed in the |
| object to an integer number. | ||
|
|
||
| Possible extensions for the new module and it's scope are discussed in the | ||
| `Open Issues <Open Issues_>`_ section. New functions are not part of the |
There was a problem hiding this comment.
New functions are not part of this Clearer for here IMO
| Module name | ||
| ----------- | ||
|
|
||
| Chosen name seems consistent with other domain-specific mathematical module: |
| Backwards Compatibility | ||
| ======================= | ||
|
|
||
| As aliases in :external+py3.14:mod:`math` will be kept for indefinite time |
There was a problem hiding this comment.
will be kept for an indefinite time
|
@StanFromIreland, please use "Start a review" instead of "Add single comment" and publish all your comments at once. The difference is that other people will get one email message instead of an message per comment. |
| Reference Implementation | ||
| ======================== | ||
|
|
||
| https://github.com/python/cpython/pull/133909 |
| Module name | ||
| ----------- | ||
|
|
||
| Chosen name seems consistent with other domain-specific mathematical module: |
| Chosen name seems consistent with other domain-specific mathematical module: | ||
| :external+py3.14:mod:`cmath` (for complex numbers). | ||
|
|
||
| There is already an ``imath`` project on PyPI, but only with two releases, with |
| :external+py3.14:mod:`cmath` (for complex numbers). | ||
|
|
||
| There is already an ``imath`` project on PyPI, but only with two releases, with | ||
| the most recent one 4 years ago. Its repository is no longer accessible. |
| There is already an ``imath`` project on PyPI, but only with two releases, with | ||
| the most recent one 4 years ago. Its repository is no longer accessible. | ||
| The `Imath <https://github.com/AcademySoftwareFoundation/Imath>`_ C++ library | ||
| include Python bindings with same name. |
| There is already an ``imath`` project on PyPI, but only with two releases, with | ||
| the most recent one 4 years ago. Its repository is no longer accessible. | ||
| The `Imath <https://github.com/AcademySoftwareFoundation/Imath>`_ C++ library | ||
| include Python bindings with same name. |
There was a problem hiding this comment.
with the same names.
I should have opened pr against this branch instead of my spew of suggestions, apologies.
| with any PyPI module. On the other hand, ``intmath`` may be confused with | ||
| interval math or numerical integration. | ||
|
|
||
| Other proposed names include ``ntheory`` (like SymPy's submodule), |
There was a problem hiding this comment.
Maybe this is better in the past tense now?
Other proposed names included
|
@StanFromIreland: You reviewed a closed PR. You should review python#4422 instead. |
|
Yes, I had not refreshed and missed it… oops. |
No description provided.