python-gmp 0.4.0b3__tar.gz → 0.4.0b5__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.
Files changed (37) hide show
  1. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/.github/workflows/ci.yml +5 -1
  2. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/.github/workflows/coverage.yml +2 -1
  3. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/.readthedocs.yaml +2 -3
  4. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/PKG-INFO +27 -17
  5. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/README.rst +26 -16
  6. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/fmt.c +1 -22
  7. python_gmp-0.4.0b3/main.c → python_gmp-0.4.0b5/gmp.c +144 -369
  8. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/meson.build +3 -3
  9. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/mpz.h +12 -1
  10. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/pyproject.toml +1 -2
  11. python_gmp-0.4.0b5/scripts/dll-importexport.diff +16 -0
  12. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/tests/conftest.py +4 -2
  13. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/tests/test_functions.py +37 -65
  14. python_gmp-0.4.0b5/tests/test_memory.py +76 -0
  15. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/tests/test_mpz.py +203 -217
  16. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/tests/test_utils.py +60 -8
  17. python_gmp-0.4.0b5/utils.c +114 -0
  18. python_gmp-0.4.0b5/utils.h +41 -0
  19. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/zz.c +13 -13
  20. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/zz.h +2 -0
  21. python_gmp-0.4.0b3/scripts/dll-importexport.diff +0 -13
  22. python_gmp-0.4.0b3/tests/test_memory.py +0 -47
  23. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/.clang-format +0 -0
  24. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/.github/dependabot.yml +0 -0
  25. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/.github/workflows/linter.yml +0 -0
  26. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/.github/workflows/os.yml +0 -0
  27. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/.github/workflows/publish.yml +0 -0
  28. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/.github/workflows/wheels.yml +0 -0
  29. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/.gitignore +0 -0
  30. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/.pre-commit-config.yaml +0 -0
  31. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/LICENSE +0 -0
  32. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/docs/conf.py +0 -0
  33. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/docs/index.rst +0 -0
  34. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/pythoncapi_compat.h +0 -0
  35. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/scripts/cibw_before_all.sh +0 -0
  36. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/scripts/fat_build_fix.diff +0 -0
  37. {python_gmp-0.4.0b3 → python_gmp-0.4.0b5}/tests/test_api.py +0 -0
@@ -1,5 +1,9 @@
1
1
  name: Run CI tests
2
- on: [push, pull_request]
2
+ on:
3
+ push:
4
+ pull_request:
5
+ schedule:
6
+ - cron: '0 0 * * 2'
3
7
  jobs:
4
8
  linter:
5
9
  uses: ./.github/workflows/linter.yml
@@ -83,7 +83,8 @@ jobs:
83
83
  token: ${{ secrets.CODECOV_TOKEN }}
84
84
  gcov_ignore: pythoncapi_compat.h
85
85
  gcov_include: fmt.c
86
- main.c
86
+ gmp.c
87
87
  zz.c
88
+ utils.c
88
89
  gcov_args: --no-external
89
90
  fail_ci_if_error: true
@@ -3,7 +3,7 @@ formats:
3
3
  - htmlzip
4
4
  - pdf
5
5
  build:
6
- os: ubuntu-22.04
6
+ os: ubuntu-24.04
7
7
  apt_packages:
8
8
  - libgmp-dev
9
9
  - gcc
@@ -11,8 +11,7 @@ build:
11
11
  python: "3"
12
12
  python:
13
13
  install:
14
- - method: pip
15
- path: .
14
+ - path: .
16
15
  extra_requirements:
17
16
  - docs
18
17
  sphinx:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-gmp
3
- Version: 0.4.0b3
3
+ Version: 0.4.0b5
4
4
  Summary: Safe bindings to the GNU GMP library
5
5
  Keywords: gmp,multiple-precision,arbitrary-precision,bignum
6
6
  Author-Email: Sergey B Kirpichev <skirpichev@gmail.com>
@@ -51,37 +51,38 @@ Description-Content-Type: text/x-rst
51
51
  Python-GMP
52
52
  ==========
53
53
 
54
- Python extension module providing safe bindings to the GNU GMP. This module
55
- shouldn't crash the interpreter!
54
+ Python extension module, gmp, providing safe bindings to the GNU GMP (version
55
+ 6.3.0 or later required). This module shouldn't crash the interpreter.
56
56
 
57
- This module can be used as a gmpy2/python-flint replacement to provide
58
- CPython-compatible integer (mpz) type. It includes few functions (factorial,
59
- gcd and isqrt), compatible with the stdlib's module math.
57
+ The gmp can be used as a `gmpy2`_/`python-flint`_ replacement to provide
58
+ integer type (`mpz`_), compatible with Python's `int`_. It includes few
59
+ functions (`factorial`_, `gcd`_ and `isqrt`_), compatible with the Python
60
+ stdlib's module `math`_.
60
61
 
61
- It requires Python 3.9 or later versions and has been tested with CPython 3.9
62
- through 3.14, for PyPy 3.11 and for GraalPy 24.2. Free-threading builds of the
63
- CPython are supported.
62
+ This module requires Python 3.9 or later versions and has been tested with
63
+ CPython 3.9 through 3.14, with PyPy 3.11 and with GraalPy 24.2. Free-threading
64
+ builds of the CPython are supported.
64
65
 
65
66
  Releases are available in the Python Package Index (PyPI) at
66
- https://pypi.org/project/python-gmp/
67
+ https://pypi.org/project/python-gmp/.
67
68
 
68
69
 
69
- Warning on alloca
70
- -----------------
70
+ Warning on --disable-alloca configure option
71
+ --------------------------------------------
71
72
 
72
73
  Most GMP packages enable using alloca() for temporary workspace allocation.
73
74
  This module can't prevent a crash in case of a stack overflow. To avoid this,
74
75
  you should compile the GMP library with '--disable-alloca' configure option to
75
76
  use rather the heap for all temporary allocations.
76
77
 
77
- Of course, published on the PyPI binary wheels aren't affected by this issue.
78
+ Published on the PyPI binary wheels aren't affected by this issue.
78
79
 
79
80
 
80
81
  Warning on using mp_set_memory_functions()
81
82
  ------------------------------------------
82
83
 
83
84
  This extension customize memory allocation routines, used by the GMP. Don't
84
- use together with other GMP bindings, like the gmpy2!
85
+ import it together with other GMP bindings, like the `gmpy2`_.
85
86
 
86
87
 
87
88
  Motivation
@@ -90,9 +91,9 @@ Motivation
90
91
  The CPython (and most other Python implementations, like PyPy) is optimized to
91
92
  work with small integers. Algorithms used here for "big enough" integers
92
93
  usually aren't best known in the field. Fortunately, it's possible to use
93
- bindings (for example, the `gmpy2 <https://pypi.org/project/gmpy2/>`_ package)
94
- to the GNU Multiple Precision Arithmetic Library (GMP), which aims to be faster
95
- than any other bignum library for all operand sizes.
94
+ bindings (for example, the `gmpy2`_ package) to the GNU Multiple Precision
95
+ Arithmetic Library (GMP), which aims to be faster than any other bignum library
96
+ for all operand sizes.
96
97
 
97
98
  But such extension modules usually rely on default GMP's memory allocation
98
99
  functions and can't recover from errors such as out of memory. So, it's easy
@@ -130,3 +131,12 @@ The gmp module handles such errors correctly:
130
131
  >>> # the current scope are available,
131
132
  >>> z.bit_length() # including pre-failure value of z
132
133
  93882077
134
+
135
+ .. _gmpy2: https://pypi.org/project/gmpy2/
136
+ .. _python-flint: https://pypi.org/project/python-flint/
137
+ .. _mpz: https://python-gmp.readthedocs.io/en/latest/#gmp.mpz
138
+ .. _int: https://docs.python.org/3/library/functions.html#int
139
+ .. _factorial: https://python-gmp.readthedocs.io/en/latest/#gmp.factorial
140
+ .. _gcd: https://python-gmp.readthedocs.io/en/latest/#gmp.gcd
141
+ .. _isqrt: https://python-gmp.readthedocs.io/en/latest/#gmp.isqrt
142
+ .. _math: https://docs.python.org/3/library/math.html#number-theoretic-functions
@@ -1,37 +1,38 @@
1
1
  Python-GMP
2
2
  ==========
3
3
 
4
- Python extension module providing safe bindings to the GNU GMP. This module
5
- shouldn't crash the interpreter!
4
+ Python extension module, gmp, providing safe bindings to the GNU GMP (version
5
+ 6.3.0 or later required). This module shouldn't crash the interpreter.
6
6
 
7
- This module can be used as a gmpy2/python-flint replacement to provide
8
- CPython-compatible integer (mpz) type. It includes few functions (factorial,
9
- gcd and isqrt), compatible with the stdlib's module math.
7
+ The gmp can be used as a `gmpy2`_/`python-flint`_ replacement to provide
8
+ integer type (`mpz`_), compatible with Python's `int`_. It includes few
9
+ functions (`factorial`_, `gcd`_ and `isqrt`_), compatible with the Python
10
+ stdlib's module `math`_.
10
11
 
11
- It requires Python 3.9 or later versions and has been tested with CPython 3.9
12
- through 3.14, for PyPy 3.11 and for GraalPy 24.2. Free-threading builds of the
13
- CPython are supported.
12
+ This module requires Python 3.9 or later versions and has been tested with
13
+ CPython 3.9 through 3.14, with PyPy 3.11 and with GraalPy 24.2. Free-threading
14
+ builds of the CPython are supported.
14
15
 
15
16
  Releases are available in the Python Package Index (PyPI) at
16
- https://pypi.org/project/python-gmp/
17
+ https://pypi.org/project/python-gmp/.
17
18
 
18
19
 
19
- Warning on alloca
20
- -----------------
20
+ Warning on --disable-alloca configure option
21
+ --------------------------------------------
21
22
 
22
23
  Most GMP packages enable using alloca() for temporary workspace allocation.
23
24
  This module can't prevent a crash in case of a stack overflow. To avoid this,
24
25
  you should compile the GMP library with '--disable-alloca' configure option to
25
26
  use rather the heap for all temporary allocations.
26
27
 
27
- Of course, published on the PyPI binary wheels aren't affected by this issue.
28
+ Published on the PyPI binary wheels aren't affected by this issue.
28
29
 
29
30
 
30
31
  Warning on using mp_set_memory_functions()
31
32
  ------------------------------------------
32
33
 
33
34
  This extension customize memory allocation routines, used by the GMP. Don't
34
- use together with other GMP bindings, like the gmpy2!
35
+ import it together with other GMP bindings, like the `gmpy2`_.
35
36
 
36
37
 
37
38
  Motivation
@@ -40,9 +41,9 @@ Motivation
40
41
  The CPython (and most other Python implementations, like PyPy) is optimized to
41
42
  work with small integers. Algorithms used here for "big enough" integers
42
43
  usually aren't best known in the field. Fortunately, it's possible to use
43
- bindings (for example, the `gmpy2 <https://pypi.org/project/gmpy2/>`_ package)
44
- to the GNU Multiple Precision Arithmetic Library (GMP), which aims to be faster
45
- than any other bignum library for all operand sizes.
44
+ bindings (for example, the `gmpy2`_ package) to the GNU Multiple Precision
45
+ Arithmetic Library (GMP), which aims to be faster than any other bignum library
46
+ for all operand sizes.
46
47
 
47
48
  But such extension modules usually rely on default GMP's memory allocation
48
49
  functions and can't recover from errors such as out of memory. So, it's easy
@@ -80,3 +81,12 @@ The gmp module handles such errors correctly:
80
81
  >>> # the current scope are available,
81
82
  >>> z.bit_length() # including pre-failure value of z
82
83
  93882077
84
+
85
+ .. _gmpy2: https://pypi.org/project/gmpy2/
86
+ .. _python-flint: https://pypi.org/project/python-flint/
87
+ .. _mpz: https://python-gmp.readthedocs.io/en/latest/#gmp.mpz
88
+ .. _int: https://docs.python.org/3/library/functions.html#int
89
+ .. _factorial: https://python-gmp.readthedocs.io/en/latest/#gmp.factorial
90
+ .. _gcd: https://python-gmp.readthedocs.io/en/latest/#gmp.gcd
91
+ .. _isqrt: https://python-gmp.readthedocs.io/en/latest/#gmp.isqrt
92
+ .. _math: https://docs.python.org/3/library/math.html#number-theoretic-functions
@@ -1,28 +1,7 @@
1
- #if defined(__clang__)
2
- # pragma GCC diagnostic push
3
- # pragma GCC diagnostic ignored "-Wnewline-eof"
4
- #endif
5
- #if defined(__GNUC__) || defined(__clang__)
6
- # pragma GCC diagnostic push
7
- # pragma GCC diagnostic ignored "-Wsign-conversion"
8
- #endif
9
-
10
- #include "pythoncapi_compat.h"
11
-
12
- #define PY_SSIZE_T_CLEAN
13
- #include <Python.h>
14
-
15
- #if defined(__GNUC__) || defined(__clang__)
16
- # pragma GCC diagnostic pop
17
- #endif
18
- #if defined(__clang__)
19
- # pragma GCC diagnostic pop
20
- #endif
1
+ #include "mpz.h"
21
2
 
22
3
  #include <locale.h>
23
4
 
24
- #include "mpz.h"
25
-
26
5
  #if !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON)
27
6
 
28
7
  static void