Skip to content

Commit b82ef40

Browse files
committed
Поехали!
0 parents  commit b82ef40

File tree

11 files changed

+3837
-0
lines changed

11 files changed

+3837
-0
lines changed

.github/workflows/basic.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: basic
2+
on: [push, pull_request]
3+
jobs:
4+
linux:
5+
strategy:
6+
fail-fast: false
7+
matrix:
8+
python-version: [3.9, '3.10', 3.11, 3.12, 3.13]
9+
os: [ubuntu-22.04]
10+
runs-on: ${{ matrix.os }}
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: ${{ matrix.python-version }}
16+
allow-prereleases: true
17+
- run: sudo apt-get update
18+
- run: sudo apt-get install libgmp-dev
19+
- run: pip install --upgrade pip
20+
- run: pip --verbose install --editable .[tests]
21+
- run: pytest

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
**.pyc
2+
**.so
3+
.hypothesis/
4+
venv/
5+
.venv/
6+
*.egg-info/
7+
*.swp
8+
build/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Sergey B Kirpichev
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# FIXME: doesn't work with package-date
2+
include *.h

README.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Python-GMP
2+
==========
3+
4+
Python extension module providing safe bindings to the GNU GMP. This module
5+
shouldn't crash the interpreter!
6+
7+
Can be used as a gmpy2/python-flint replacement to provide CPython-compatible
8+
integer and rational types:
9+
10+
* mpz --- like builtin int int type
11+
* mpq --- like stdlib's Fraction type
12+
13+
Module includes also few functions:
14+
15+
* gcd --- greatest common division, just like math.gcd
16+
* isqrt --- integer square root, just like math.isqrt

TODO

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Overall:
2+
- naming && formatting
3+
- test coverage (add examples for corner cases, errors)
4+
- memory management (remove dealloc?)
5+
- README.rst
6+
- benchmark (basic, e.g. multiplication)
7+
- CI (basic tests)
8+
- asserts
9+
- publish
10+
- transform TODO to issues
11+
- try in mpmath/diofant
12+
- split-out low-level (non-Python) library with "safe" zz/qq types
13+
- CI (cibuildwheel with M$)
14+
- work with PyPy?
15+
- mixed-mode operations (with float)?
16+
- specialize small integers case (see flint, cpython and faster-python/ideas)?
17+
- support optionally mpq output in __truediv__
18+
19+
Missing features:
20+
- more input validation (invalid digits, etc)
21+
- float(mpz(int)) doesn't match float(int) (as for gmpy2)
22+
- repr as mpz(str)
23+
- pickle protocols 0 and 1
24+
- allow subclasses
25+
- fast mpz<->int (now uses temporary hex strings)
26+
27+
Missing mpz dunders:
28+
- __round__
29+
- __pow__ (3-arg case, floating-point args)
30+
- __truediv__
31+
- __format__ (like int)
32+
- __lshift__
33+
- __rshift__
34+
35+
Missing mpz methods:
36+
- from_bytes/to_bytes
37+
- is_probab_prime ?
38+
39+
Missing types:
40+
- mpq
41+
42+
Missing functions:
43+
- factorial // diofant/sympy
44+
- isqrt_rem, factorial2, fib // mpmath

0 commit comments

Comments
 (0)