diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2020-02-23 11:21:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-23 11:21:29 (GMT) |
commit | 559e7f165ad03731e6bc2211c0e6d8d9c02fb549 (patch) | |
tree | 0cf0f31bae98ea188a5fde21a1db4c068539dbdb /Modules/clinic/mathmodule.c.h | |
parent | fbe2e0bb8a7ee75d0f9d57682436dac7d69e202e (diff) | |
download | cpython-559e7f165ad03731e6bc2211c0e6d8d9c02fb549.zip cpython-559e7f165ad03731e6bc2211c0e6d8d9c02fb549.tar.gz cpython-559e7f165ad03731e6bc2211c0e6d8d9c02fb549.tar.bz2 |
bpo-39648: Expand math.gcd() and math.lcm() to handle multiple arguments. (GH-18604)
* bpo-39648: Expand math.gcd() and math.lcm() to handle multiple arguments.
* Simplify fast path.
* Difine lcm() without arguments returning 1.
* Apply suggestions from code review
Co-Authored-By: Mark Dickinson <dickinsm@gmail.com>
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
Diffstat (limited to 'Modules/clinic/mathmodule.c.h')
-rw-r--r-- | Modules/clinic/mathmodule.c.h | 62 |
1 files changed, 1 insertions, 61 deletions
diff --git a/Modules/clinic/mathmodule.c.h b/Modules/clinic/mathmodule.c.h index df45a1a..65f3dd4 100644 --- a/Modules/clinic/mathmodule.c.h +++ b/Modules/clinic/mathmodule.c.h @@ -2,36 +2,6 @@ preserve [clinic start generated code]*/ -PyDoc_STRVAR(math_gcd__doc__, -"gcd($module, x, y, /)\n" -"--\n" -"\n" -"greatest common divisor of x and y"); - -#define MATH_GCD_METHODDEF \ - {"gcd", (PyCFunction)(void(*)(void))math_gcd, METH_FASTCALL, math_gcd__doc__}, - -static PyObject * -math_gcd_impl(PyObject *module, PyObject *a, PyObject *b); - -static PyObject * -math_gcd(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *a; - PyObject *b; - - if (!_PyArg_CheckPositional("gcd", nargs, 2, 2)) { - goto exit; - } - a = args[0]; - b = args[1]; - return_value = math_gcd_impl(module, a, b); - -exit: - return return_value; -} - PyDoc_STRVAR(math_ceil__doc__, "ceil($module, x, /)\n" "--\n" @@ -85,36 +55,6 @@ PyDoc_STRVAR(math_factorial__doc__, #define MATH_FACTORIAL_METHODDEF \ {"factorial", (PyCFunction)math_factorial, METH_O, math_factorial__doc__}, -PyDoc_STRVAR(math_lcm__doc__, -"lcm($module, x, y, /)\n" -"--\n" -"\n" -"least common multiple of x and y"); - -#define MATH_LCM_METHODDEF \ - {"lcm", (PyCFunction)(void(*)(void))math_lcm, METH_FASTCALL, math_lcm__doc__}, - -static PyObject * -math_lcm_impl(PyObject *module, PyObject *a, PyObject *b); - -static PyObject * -math_lcm(PyObject *module, PyObject *const *args, Py_ssize_t nargs) -{ - PyObject *return_value = NULL; - PyObject *a; - PyObject *b; - - if (!_PyArg_CheckPositional("lcm", nargs, 2, 2)) { - goto exit; - } - a = args[0]; - b = args[1]; - return_value = math_lcm_impl(module, a, b); - -exit: - return return_value; -} - PyDoc_STRVAR(math_trunc__doc__, "trunc($module, x, /)\n" "--\n" @@ -925,4 +865,4 @@ math_ulp(PyObject *module, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=f8daa185c043a7b7 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1eae2b3ef19568fa input=a9049054013a1b77]*/ |