@@ -51,6 +51,7 @@ Currently the :external+py3.14:mod:`math` module code in the CPython is around
51
51
comparable with the :external+py3.14:mod: `cmath ` (1340LOC), which is *not * a
52
52
simple wrapper to the ``libm ``, as most functions in the
53
53
:external+py3.14:mod: `math ` module.
54
+
54
55
And this situation tends to get worse. When the module split `was first
55
56
proposed
56
57
<https://mail.python.org/archives/list/[email protected] /thread/YYJ5YJBJNCVXQWK5K3WSVNMPUSV56LOR/> `_,
@@ -59,6 +60,23 @@ there were only two integer-related functions:
59
60
Now there are six and :external+py3.14:func: `~math.factorial ` doesn't accept
60
61
:class: `float `'s anymore.
61
62
63
+ Some possible additions, among those proposed in the initial discussion thread
64
+ and issue
65
+ `python/cpython#81313 <https://github.com/python/cpython/issues/81313 >`_ are:
66
+
67
+ * ``ceil_div() `` --- for integer ceiling divide, see
68
+ `relevant discussion thread <https://discuss.python.org/t/91269 >`_.
69
+ * ``gcdext() `` --- to solve linear `Diophantine equation <https://en.wikipedia.org/wiki/Diophantine_equation >`_ in two variables (the
70
+ :external+py3.14:class: `int ` implementation actually includes an extended
71
+ Euclidean algorithm)
72
+ * ``isqrt_rem() `` --- to return both an integer square root and a remainder (which is non-zero only if
73
+ the integer isn't a perfect square)
74
+ * ``ilog() `` --- integer logarithm, :external+py3.14:func: `math.log `
75
+ has special handling for integer arguments. It's unique (with respect to other module
76
+ functions) and not documented so far, see issue
77
+ `python/cpython#120950 <https://github.com/python/cpython/issues/120950 >`_.
78
+ * ``fibonacci() `` --- `Fibonacci sequence <https://en.wikipedia.org/wiki/Fibonacci_sequence >`_.
79
+
62
80
63
81
Rationale
64
82
=========
@@ -98,9 +116,21 @@ Module functions will accept integers and objects that implement the
98
116
object to an integer number. Suitable functions must be computed exactly,
99
117
given sufficient time and memory.
100
118
101
- Possible extensions for the new module and its scope are discussed in the
102
- `Open Issues <Open Issues _>`_ section. New functions are not part of this
103
- proposal.
119
+
120
+ Possible Extensions
121
+ ===================
122
+
123
+ New functions (like mentioned in `Motivation <Motivation _>`_ section) are not
124
+ part of this proposal.
125
+
126
+ Though, we should mention that, unless we can just provide bindings to some
127
+ well supported mathematical library like the GMP, the module scope should be
128
+ limited. For example, no primality testing and factorization, as
129
+ production-quality implementatons will require a decent mathematical background
130
+ from contributors and belongs rather to specialized libraries.
131
+
132
+ When proposed function already exists in the :pypi: `gmpy2 `, we should prefer a
133
+ compatible interface for the stdlib.
104
134
105
135
106
136
Backwards Compatibility
@@ -131,39 +161,6 @@ Reference Implementation
131
161
`python/cpython#133909 <https://github.com/python/cpython/pull/133909 >`_
132
162
133
163
134
- Open Issues
135
- ===========
136
-
137
- Module scope and possible extensions
138
- ------------------------------------
139
-
140
- Unless we can just provide bindings to some well supported mathematical library
141
- like the GMP, the module scope should be limited. For example, no primality
142
- testing and factorization, as production-quality implementatons will require a
143
- decent mathematical background from contributors and belongs rather to
144
- specialized libraries.
145
-
146
- Some possible additions, among those proposed in the initial discussion thread
147
- (see also issue
148
- `python/cpython#81313 <https://github.com/python/cpython/issues/81313 >`_):
149
-
150
- * ``ceil_div() `` --- for integer ceiling divide, see
151
- `relevant discussion thread <https://discuss.python.org/t/91269 >`_.
152
- * ``gcdext() `` --- to solve linear `Diophantine equation <https://en.wikipedia.org/wiki/Diophantine_equation >`_ in two variables (the
153
- :external+py3.14:class: `int ` implementation actually includes an extended
154
- Euclidean algorithm)
155
- * ``isqrt_rem() `` --- to return both an integer square root and a remainder (which is non-zero only if
156
- the integer isn't a perfect square)
157
- * ``ilog() `` --- integer logarithm, :external+py3.14:func: `math.log `
158
- has special handling for integer arguments. It's unique (with respect to other module
159
- functions) and not documented so far, see issue
160
- `python/cpython#120950 <https://github.com/python/cpython/issues/120950 >`_.
161
- * ``fibonacci() `` --- `Fibonacci sequence <https://en.wikipedia.org/wiki/Fibonacci_sequence >`_.
162
-
163
- When proposed function already exists in the :pypi: `gmpy2 `, we should prefer a
164
- compatible interface for the stdlib.
165
-
166
-
167
164
Rejected ideas
168
165
==============
169
166
0 commit comments