cfractions 2.2.0__tar.gz → 2.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ include cfractions/py.typed
2
+ include LICENSE
3
+ recursive-include src *.c
@@ -1,26 +1,50 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cfractions
3
- Version: 2.2.0
3
+ Version: 2.4.0
4
4
  Summary: Python C API alternative to `fractions` module.
5
5
  Home-page: https://github.com/lycantropos/cfractions/
6
6
  Download-URL: https://github.com/lycantropos/cfractions/archive/master.zip
7
- Author: Azat Ibrakov
8
- Author-email: azatibrakov@gmail.com
7
+ Author-email: Azat Ibrakov <azatibrakov@gmail.com>
9
8
  License: MIT License
9
+
10
+ Copyright (c) 2021 Azat Ibrakov
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+
10
30
  Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3.7
12
- Classifier: Programming Language :: Python :: 3.8
13
31
  Classifier: Programming Language :: Python :: 3.9
14
32
  Classifier: Programming Language :: Python :: 3.10
15
33
  Classifier: Programming Language :: Python :: 3.11
34
+ Classifier: Programming Language :: Python :: 3.12
35
+ Classifier: Programming Language :: Python :: 3.13
16
36
  Classifier: Programming Language :: Python :: Implementation :: CPython
17
37
  Classifier: Programming Language :: Python :: Implementation :: PyPy
18
- Requires-Python: >=3.7
38
+ Requires-Python: >=3.9
19
39
  Description-Content-Type: text/markdown
20
40
  License-File: LICENSE
41
+ Requires-Dist: typing-extensions<5.0,>=4.12.2
42
+ Provides-Extra: tests
43
+ Requires-Dist: hypothesis<7.0,>=6.118.8; extra == "tests"
44
+ Requires-Dist: pytest<9.0,>=8.3.3; extra == "tests"
21
45
 
22
46
  cfractions
23
- ==========
47
+ ========
24
48
 
25
49
  [![](https://github.com/lycantropos/cfractions/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/lycantropos/cfractions/actions/workflows/ci.yml "Github Actions")
26
50
  [![](https://codecov.io/gh/lycantropos/cfractions/branch/master/graph/badge.svg)](https://codecov.io/gh/lycantropos/cfractions "Codecov")
@@ -36,13 +60,13 @@ written using [`Python C API`](https://docs.python.org/c-api/index.html).
36
60
  Main features are:
37
61
  - speed & memory efficiency compared to pure-`Python` counterpart,
38
62
  - full spectre of arithmetic & comparison operations,
39
- - `Python3.6+` support,
63
+ - `Python3.9+` support,
40
64
  - `PyPy` support (by falling back to `fractions.Fraction` proxy).
41
65
 
42
66
  ---
43
67
 
44
- In what follows `python` is an alias for `python3.7` or `pypy3.7`
45
- or any later version (`python3.8`, `pypy3.8` and so on).
68
+ In what follows `python` is an alias for `python3.9` or `pypy3.9`
69
+ or any later version (`python3.10`, `pypy3.10` and so on).
46
70
 
47
71
  Installation
48
72
  ------------
@@ -69,7 +93,7 @@ cd cfractions
69
93
 
70
94
  Install
71
95
  ```bash
72
- python setup.py install
96
+ python -m pip install -e .
73
97
  ```
74
98
 
75
99
  Usage
@@ -131,7 +155,7 @@ Bump version
131
155
  bump2version --verbose $CATEGORY
132
156
  ```
133
157
 
134
- This will set version to `major.minor.patch-alpha`.
158
+ This will set version to `major.minor.patch-alpha`.
135
159
 
136
160
  #### Release
137
161
 
@@ -149,9 +173,9 @@ This will set version to `major.minor.patch`.
149
173
 
150
174
  ### Running tests
151
175
 
152
- Install dependencies
176
+ Install with dependencies
153
177
  ```bash
154
- python -m pip install -r requirements-tests.txt
178
+ python -m pip install -e .[tests]
155
179
  ```
156
180
 
157
181
  Plain
@@ -1,5 +1,5 @@
1
1
  cfractions
2
- ==========
2
+ ========
3
3
 
4
4
  [![](https://github.com/lycantropos/cfractions/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/lycantropos/cfractions/actions/workflows/ci.yml "Github Actions")
5
5
  [![](https://codecov.io/gh/lycantropos/cfractions/branch/master/graph/badge.svg)](https://codecov.io/gh/lycantropos/cfractions "Codecov")
@@ -15,13 +15,13 @@ written using [`Python C API`](https://docs.python.org/c-api/index.html).
15
15
  Main features are:
16
16
  - speed & memory efficiency compared to pure-`Python` counterpart,
17
17
  - full spectre of arithmetic & comparison operations,
18
- - `Python3.6+` support,
18
+ - `Python3.9+` support,
19
19
  - `PyPy` support (by falling back to `fractions.Fraction` proxy).
20
20
 
21
21
  ---
22
22
 
23
- In what follows `python` is an alias for `python3.7` or `pypy3.7`
24
- or any later version (`python3.8`, `pypy3.8` and so on).
23
+ In what follows `python` is an alias for `python3.9` or `pypy3.9`
24
+ or any later version (`python3.10`, `pypy3.10` and so on).
25
25
 
26
26
  Installation
27
27
  ------------
@@ -48,7 +48,7 @@ cd cfractions
48
48
 
49
49
  Install
50
50
  ```bash
51
- python setup.py install
51
+ python -m pip install -e .
52
52
  ```
53
53
 
54
54
  Usage
@@ -110,7 +110,7 @@ Bump version
110
110
  bump2version --verbose $CATEGORY
111
111
  ```
112
112
 
113
- This will set version to `major.minor.patch-alpha`.
113
+ This will set version to `major.minor.patch-alpha`.
114
114
 
115
115
  #### Release
116
116
 
@@ -128,9 +128,9 @@ This will set version to `major.minor.patch`.
128
128
 
129
129
  ### Running tests
130
130
 
131
- Install dependencies
131
+ Install with dependencies
132
132
  ```bash
133
- python -m pip install -r requirements-tests.txt
133
+ python -m pip install -e .[tests]
134
134
  ```
135
135
 
136
136
  Plain
@@ -0,0 +1,332 @@
1
+ """Python C API alternative to `fractions` module."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ __version__ = '2.4.0'
8
+
9
+ if TYPE_CHECKING:
10
+ import numbers as _numbers
11
+ from fractions import Fraction as _Fraction
12
+ from typing import Any as _Any, Union as _Union
13
+
14
+ from typing_extensions import (
15
+ Self as _Self,
16
+ final as _final,
17
+ overload as _overload,
18
+ )
19
+
20
+ _Rational = _Union[_Fraction, _numbers.Rational, int]
21
+
22
+ @_final
23
+ class Fraction:
24
+ @property
25
+ def numerator(self, /) -> int: ...
26
+
27
+ @property
28
+ def denominator(self, /) -> int: ...
29
+
30
+ def as_integer_ratio(self, /) -> tuple[int, int]: ...
31
+
32
+ def is_integer(self, /) -> bool: ...
33
+
34
+ def limit_denominator(
35
+ self, max_denominator: int = 10**6, /
36
+ ) -> _Self: ...
37
+
38
+ @_overload
39
+ def __new__(
40
+ cls, value: _Rational | _Self | float | str = ..., _: None = ..., /
41
+ ) -> _Self: ...
42
+
43
+ @_overload
44
+ def __new__(cls, numerator: int, denominator: int, /) -> _Self: ...
45
+
46
+ def __new__(
47
+ cls,
48
+ numerator: _Rational | _Self | float | str = 0,
49
+ denominator: int | None = None,
50
+ /,
51
+ ) -> _Self: ...
52
+
53
+ def __abs__(self, /) -> _Self: ...
54
+
55
+ @_overload
56
+ def __add__(self, other: _Rational | _Self, /) -> _Self: ...
57
+
58
+ @_overload
59
+ def __add__(self, other: float, /) -> float: ...
60
+
61
+ @_overload
62
+ def __add__(self, other: _Any, /) -> _Any: ...
63
+
64
+ def __add__(self, other: _Any, /) -> _Any: ...
65
+
66
+ def __ceil__(self, /) -> int: ...
67
+
68
+ def __copy__(self, /) -> _Self: ...
69
+
70
+ def __deepcopy__(
71
+ self, memo: dict[str, _Any] | None = None, /
72
+ ) -> _Self: ...
73
+
74
+ @_overload
75
+ def __divmod__(
76
+ self, divisor: _Rational | _Self, /
77
+ ) -> tuple[int, _Self]: ...
78
+
79
+ @_overload
80
+ def __divmod__(self, divisor: float, /) -> tuple[float, float]: ...
81
+
82
+ @_overload
83
+ def __divmod__(self, divisor: _Any, /) -> _Any: ...
84
+
85
+ def __divmod__(self, divisor: _Any, /) -> _Any: ...
86
+
87
+ @_overload
88
+ def __eq__(self, other: _Rational | _Self | float, /) -> bool: ...
89
+
90
+ @_overload
91
+ def __eq__(self, other: _Any, /) -> _Any: ...
92
+
93
+ def __eq__(self, other: _Any, /) -> _Any: ...
94
+
95
+ def __float__(self, /) -> float: ...
96
+
97
+ def __floor__(self, /) -> int: ...
98
+
99
+ @_overload
100
+ def __floordiv__(self, divisor: _Rational | _Self, /) -> int: ...
101
+
102
+ @_overload
103
+ def __floordiv__(self, divisor: float, /) -> float: ...
104
+
105
+ @_overload
106
+ def __floordiv__(self, divisor: _Any, /) -> _Any: ...
107
+
108
+ def __floordiv__(self, divisor: _Any, /) -> _Any: ...
109
+
110
+ @_overload
111
+ def __ge__(self, other: _Rational | _Self, /) -> bool: ...
112
+
113
+ @_overload
114
+ def __ge__(self, other: float, /) -> bool: ...
115
+
116
+ @_overload
117
+ def __ge__(self, other: _Any, /) -> _Any: ...
118
+
119
+ def __ge__(self, other: _Any, /) -> _Any: ...
120
+
121
+ @_overload
122
+ def __gt__(self, other: _Rational | _Self, /) -> bool: ...
123
+
124
+ @_overload
125
+ def __gt__(self, other: float, /) -> bool: ...
126
+
127
+ @_overload
128
+ def __gt__(self, other: _Any, /) -> _Any: ...
129
+
130
+ def __gt__(self, other: _Any, /) -> _Any: ...
131
+
132
+ def __hash__(self, /) -> int: ...
133
+
134
+ def __int__(self, /) -> int: ...
135
+
136
+ @_overload
137
+ def __le__(self, other: _Rational | _Self, /) -> bool: ...
138
+
139
+ @_overload
140
+ def __le__(self, other: float, /) -> bool: ...
141
+
142
+ @_overload
143
+ def __le__(self, other: _Any, /) -> _Any: ...
144
+
145
+ def __le__(self, other: _Any, /) -> _Any: ...
146
+
147
+ @_overload
148
+ def __lt__(self, other: _Rational | _Self, /) -> bool: ...
149
+
150
+ @_overload
151
+ def __lt__(self, other: float, /) -> bool: ...
152
+
153
+ @_overload
154
+ def __lt__(self, other: _Any, /) -> _Any: ...
155
+
156
+ def __lt__(self, other: _Any, /) -> _Any: ...
157
+
158
+ @_overload
159
+ def __mod__(self, divisor: _Rational | _Self, /) -> _Self: ...
160
+
161
+ @_overload
162
+ def __mod__(self, divisor: float, /) -> float: ...
163
+
164
+ @_overload
165
+ def __mod__(self, divisor: _Any, /) -> _Any: ...
166
+
167
+ def __mod__(self, divisor: _Any, /) -> _Any: ...
168
+
169
+ @_overload
170
+ def __mul__(self, other: _Rational | _Self, /) -> _Self: ...
171
+
172
+ @_overload
173
+ def __mul__(self, other: float, /) -> float: ...
174
+
175
+ @_overload
176
+ def __mul__(self, other: _Any, /) -> _Any: ...
177
+
178
+ def __mul__(self, other: _Any, /) -> _Any: ...
179
+
180
+ def __neg__(self, /) -> _Self: ...
181
+
182
+ def __pos__(self, /) -> _Self: ...
183
+
184
+ @_overload
185
+ def __pow__(self, exponent: int, /) -> _Self: ...
186
+
187
+ @_overload
188
+ def __pow__(self, exponent: _Rational | _Self, /) -> _Self | float: ...
189
+
190
+ @_overload
191
+ def __pow__(self, exponent: float, /) -> float: ...
192
+
193
+ @_overload
194
+ def __pow__(self, exponent: _Any, /) -> _Any: ...
195
+
196
+ def __pow__(self, exponent: _Any, /) -> _Any: ...
197
+
198
+ @_overload
199
+ def __radd__(self, other: _Rational, /) -> _Self: ...
200
+
201
+ @_overload
202
+ def __radd__(self, other: float, /) -> float: ...
203
+
204
+ @_overload
205
+ def __radd__(self, other: _Any, /) -> _Any: ...
206
+
207
+ def __radd__(self, other: _Any, /) -> _Any: ...
208
+
209
+ @_overload
210
+ def __rdivmod__(self, dividend: _Rational, /) -> tuple[int, _Self]: ...
211
+
212
+ @_overload
213
+ def __rdivmod__(self, dividend: float, /) -> tuple[float, float]: ...
214
+
215
+ @_overload
216
+ def __rdivmod__(self, dividend: _Any, /) -> _Any: ...
217
+
218
+ def __rdivmod__(self, dividend: _Any, /) -> _Any: ...
219
+
220
+ def __repr__(self) -> str: ...
221
+
222
+ @_overload
223
+ def __rfloordiv__(self, dividend: _Rational, /) -> int: ...
224
+
225
+ @_overload
226
+ def __rfloordiv__(self, dividend: float, /) -> float: ...
227
+
228
+ @_overload
229
+ def __rfloordiv__(self, dividend: _Any, /) -> _Any: ...
230
+
231
+ def __rfloordiv__(self, dividend: _Any, /) -> _Any: ...
232
+
233
+ @_overload
234
+ def __rmod__(self, dividend: _Rational, /) -> _Self: ...
235
+
236
+ @_overload
237
+ def __rmod__(self, dividend: float, /) -> float: ...
238
+
239
+ @_overload
240
+ def __rmod__(self, dividend: _Any, /) -> _Any: ...
241
+
242
+ def __rmod__(self, dividend: _Any, /) -> _Any: ...
243
+
244
+ @_overload
245
+ def __rmul__(self, other: _Rational, /) -> _Self: ...
246
+
247
+ @_overload
248
+ def __rmul__(self, other: float, /) -> float: ...
249
+
250
+ @_overload
251
+ def __rmul__(self, other: _Any, /) -> _Any: ...
252
+
253
+ def __rmul__(self, other: _Any, /) -> _Any: ...
254
+
255
+ @_overload
256
+ def __round__(self, precision: None = ..., /) -> int: ...
257
+
258
+ @_overload
259
+ def __round__(self, precision: int, /) -> _Self: ...
260
+
261
+ def __round__(
262
+ self, precision: int | None = None, /
263
+ ) -> int | _Self: ...
264
+
265
+ @_overload
266
+ def __rpow__(self, base: _Rational, /) -> _Self | float: ...
267
+
268
+ @_overload
269
+ def __rpow__(self, base: float, /) -> float: ...
270
+
271
+ @_overload
272
+ def __rpow__(self, base: _Any, /) -> _Any: ...
273
+
274
+ def __rpow__(self, base: _Any, /) -> _Any: ...
275
+
276
+ @_overload
277
+ def __rsub__(self, minuend: _Rational, /) -> _Self: ...
278
+
279
+ @_overload
280
+ def __rsub__(self, minuend: float, /) -> float: ...
281
+
282
+ @_overload
283
+ def __rsub__(self, minuend: _Any, /) -> _Any: ...
284
+
285
+ def __rsub__(self, minuend: _Any, /) -> _Any: ...
286
+
287
+ @_overload
288
+ def __rtruediv__(self, dividend: _Rational, /) -> _Self: ...
289
+
290
+ @_overload
291
+ def __rtruediv__(self, dividend: float, /) -> float: ...
292
+
293
+ @_overload
294
+ def __rtruediv__(self, dividend: _Any, /) -> _Any: ...
295
+
296
+ def __rtruediv__(self, dividend: _Any, /) -> _Any: ...
297
+
298
+ def __str__(self) -> str: ...
299
+
300
+ @_overload
301
+ def __sub__(self, subtrahend: _Rational | _Self, /) -> _Self: ...
302
+
303
+ @_overload
304
+ def __sub__(self, subtrahend: float, /) -> float: ...
305
+
306
+ @_overload
307
+ def __sub__(self, subtrahend: _Any, /) -> _Any: ...
308
+
309
+ def __sub__(self, subtrahend: _Any, /) -> _Any: ...
310
+
311
+ @_overload
312
+ def __truediv__(self, divisor: _Rational | _Self, /) -> _Self: ...
313
+
314
+ @_overload
315
+ def __truediv__(self, divisor: float, /) -> float: ...
316
+
317
+ @_overload
318
+ def __truediv__(self, divisor: _Any, /) -> _Any: ...
319
+
320
+ def __truediv__(self, divisor: _Any, /) -> _Any: ...
321
+
322
+ def __trunc__(self, /) -> int: ...
323
+
324
+ else:
325
+ try:
326
+ from . import _cfractions
327
+ except ImportError:
328
+ from . import _fractions
329
+
330
+ Fraction = _fractions.Fraction
331
+ else:
332
+ Fraction = _cfractions.Fraction