diff --git a/docs/conf.py b/docs/conf.py index 91cdf837..882c4194 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -48,7 +48,7 @@ # General information about the project. project = gmpy2.__package__ -copyright = '2012 - 2023, Case Van Horsen' +copyright = '2012 - 2024, Case Van Horsen' gmpy2_version = packaging.version.parse(gmpy2.__version__) diff --git a/src/gmpy2.c b/src/gmpy2.c index e07faf3a..aab8c22d 100644 --- a/src/gmpy2.c +++ b/src/gmpy2.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * @@ -708,10 +708,10 @@ static PyMethodDef Pygmpy_methods [] = { "bit_scan1", (PyCFunction)GMPy_MPZ_bit_scan1_function, METH_FASTCALL, doc_bit_scan1_function }, { "bit_set", GMPy_MPZ_bit_set_function, METH_VARARGS, doc_bit_set_function }, { "bit_test", (PyCFunction)GMPy_MPZ_bit_test_function, METH_FASTCALL, doc_bit_test_function }, - { "bincoef", GMPy_MPZ_Function_Bincoef, METH_VARARGS, GMPy_doc_mpz_function_bincoef }, + { "bincoef", (PyCFunction)GMPy_MPZ_Function_Bincoef, METH_FASTCALL, GMPy_doc_mpz_function_bincoef }, { "cmp", GMPy_MPANY_cmp, METH_VARARGS, GMPy_doc_mpany_cmp }, { "cmp_abs", GMPy_MPANY_cmp_abs, METH_VARARGS, GMPy_doc_mpany_cmp_abs }, - { "comb", GMPy_MPZ_Function_Bincoef, METH_VARARGS, GMPy_doc_mpz_function_comb }, + { "comb", (PyCFunction)GMPy_MPZ_Function_Bincoef, METH_FASTCALL, GMPy_doc_mpz_function_comb }, { "c_div", GMPy_MPZ_c_div, METH_VARARGS, doc_c_div }, { "c_div_2exp", GMPy_MPZ_c_div_2exp, METH_VARARGS, doc_c_div_2exp }, { "c_divmod", GMPy_MPZ_c_divmod, METH_VARARGS, doc_c_divmod }, @@ -721,8 +721,8 @@ static PyMethodDef Pygmpy_methods [] = { "denom", GMPy_MPQ_Function_Denom, METH_O, GMPy_doc_mpq_function_denom }, { "digits", GMPy_Context_Digits, METH_VARARGS, GMPy_doc_context_digits }, { "div", GMPy_Context_TrueDiv, METH_VARARGS, GMPy_doc_truediv }, - { "divexact", GMPy_MPZ_Function_Divexact, METH_VARARGS, GMPy_doc_mpz_function_divexact }, - { "divm", GMPy_MPZ_Function_Divm, METH_VARARGS, GMPy_doc_mpz_function_divm }, + { "divexact", (PyCFunction)GMPy_MPZ_Function_Divexact, METH_FASTCALL, GMPy_doc_mpz_function_divexact }, + { "divm", (PyCFunction)GMPy_MPZ_Function_Divm, METH_FASTCALL, GMPy_doc_mpz_function_divm }, { "double_fac", GMPy_MPZ_Function_DoubleFac, METH_O, GMPy_doc_mpz_function_double_fac }, { "fac", GMPy_MPZ_Function_Fac, METH_O, GMPy_doc_mpz_function_fac }, { "fib", GMPy_MPZ_Function_Fib, METH_O, GMPy_doc_mpz_function_fib }, @@ -736,16 +736,16 @@ static PyMethodDef Pygmpy_methods [] = { "f_mod", GMPy_MPZ_f_mod, METH_VARARGS, doc_f_mod }, { "f_mod_2exp", GMPy_MPZ_f_mod_2exp, METH_VARARGS, doc_f_mod_2exp }, { "gcd", (PyCFunction)GMPy_MPZ_Function_GCD, METH_FASTCALL, GMPy_doc_mpz_function_gcd }, - { "gcdext", GMPy_MPZ_Function_GCDext, METH_VARARGS, GMPy_doc_mpz_function_gcdext }, + { "gcdext", (PyCFunction)GMPy_MPZ_Function_GCDext, METH_FASTCALL, GMPy_doc_mpz_function_gcdext }, { "hamdist", GMPy_MPZ_hamdist, METH_VARARGS, doc_hamdist }, - { "invert", GMPy_MPZ_Function_Invert, METH_VARARGS, GMPy_doc_mpz_function_invert }, - { "iroot", GMPy_MPZ_Function_Iroot, METH_VARARGS, GMPy_doc_mpz_function_iroot }, - { "iroot_rem", GMPy_MPZ_Function_IrootRem, METH_VARARGS, GMPy_doc_mpz_function_iroot_rem }, + { "invert", (PyCFunction)GMPy_MPZ_Function_Invert, METH_FASTCALL, GMPy_doc_mpz_function_invert }, + { "iroot", (PyCFunction)GMPy_MPZ_Function_Iroot, METH_FASTCALL, GMPy_doc_mpz_function_iroot }, + { "iroot_rem", (PyCFunction)GMPy_MPZ_Function_IrootRem, METH_FASTCALL, GMPy_doc_mpz_function_iroot_rem }, { "isqrt", GMPy_MPZ_Function_Isqrt, METH_O, GMPy_doc_mpz_function_isqrt }, { "isqrt_rem", GMPy_MPZ_Function_IsqrtRem, METH_O, GMPy_doc_mpz_function_isqrt_rem }, { "is_bpsw_prp", GMPY_mpz_is_bpsw_prp, METH_VARARGS, doc_mpz_is_bpsw_prp }, - { "is_congruent", GMPy_MPZ_Function_IsCongruent, METH_VARARGS, GMPy_doc_mpz_function_is_congruent }, - { "is_divisible", GMPy_MPZ_Function_IsDivisible, METH_VARARGS, GMPy_doc_mpz_function_is_divisible }, + { "is_congruent", (PyCFunction)GMPy_MPZ_Function_IsCongruent, METH_FASTCALL, GMPy_doc_mpz_function_is_congruent }, + { "is_divisible", (PyCFunction)GMPy_MPZ_Function_IsDivisible, METH_FASTCALL, GMPy_doc_mpz_function_is_divisible }, { "is_even", GMPy_MPZ_Function_IsEven, METH_O, GMPy_doc_mpz_function_is_even }, { "is_euler_prp", GMPY_mpz_is_euler_prp, METH_VARARGS, doc_mpz_is_euler_prp }, { "is_extra_strong_lucas_prp", GMPY_mpz_is_extrastronglucas_prp, METH_VARARGS, doc_mpz_is_extrastronglucas_prp }, @@ -754,7 +754,7 @@ static PyMethodDef Pygmpy_methods [] = { "is_lucas_prp", GMPY_mpz_is_lucas_prp, METH_VARARGS, doc_mpz_is_lucas_prp }, { "is_odd", GMPy_MPZ_Function_IsOdd, METH_O, GMPy_doc_mpz_function_is_odd }, { "is_power", GMPy_MPZ_Function_IsPower, METH_O, GMPy_doc_mpz_function_is_power }, - { "is_prime", GMPy_MPZ_Function_IsPrime, METH_VARARGS, GMPy_doc_mpz_function_is_prime }, + { "is_prime", (PyCFunction)GMPy_MPZ_Function_IsPrime, METH_FASTCALL, GMPy_doc_mpz_function_is_prime }, { "is_probab_prime", (PyCFunction)GMPy_MPZ_Function_IsProbabPrime, METH_FASTCALL, GMPy_doc_mpz_function_is_probab_prime }, { "is_selfridge_prp", GMPY_mpz_is_selfridge_prp, METH_VARARGS, doc_mpz_is_selfridge_prp }, { "is_square", GMPy_MPZ_Function_IsSquare, METH_O, GMPy_doc_mpz_function_is_square }, @@ -762,10 +762,10 @@ static PyMethodDef Pygmpy_methods [] = { "is_strong_bpsw_prp", GMPY_mpz_is_strongbpsw_prp, METH_VARARGS, doc_mpz_is_strongbpsw_prp }, { "is_strong_lucas_prp", GMPY_mpz_is_stronglucas_prp, METH_VARARGS, doc_mpz_is_stronglucas_prp }, { "is_strong_selfridge_prp", GMPY_mpz_is_strongselfridge_prp, METH_VARARGS, doc_mpz_is_strongselfridge_prp }, - { "jacobi", GMPy_MPZ_Function_Jacobi, METH_VARARGS, GMPy_doc_mpz_function_jacobi }, - { "kronecker", GMPy_MPZ_Function_Kronecker, METH_VARARGS, GMPy_doc_mpz_function_kronecker }, + { "jacobi", (PyCFunction)GMPy_MPZ_Function_Jacobi, METH_FASTCALL, GMPy_doc_mpz_function_jacobi }, + { "kronecker", (PyCFunction)GMPy_MPZ_Function_Kronecker, METH_FASTCALL, GMPy_doc_mpz_function_kronecker }, { "lcm", (PyCFunction)GMPy_MPZ_Function_LCM, METH_FASTCALL, GMPy_doc_mpz_function_lcm }, - { "legendre", GMPy_MPZ_Function_Legendre, METH_VARARGS, GMPy_doc_mpz_function_legendre }, + { "legendre", (PyCFunction)GMPy_MPZ_Function_Legendre, METH_FASTCALL, GMPy_doc_mpz_function_legendre }, { "license", GMPy_get_license, METH_NOARGS, GMPy_doc_license }, { "lucas", GMPy_MPZ_Function_Lucas, METH_O, GMPy_doc_mpz_function_lucas }, { "lucasu", GMPY_mpz_lucasu, METH_VARARGS, doc_mpz_lucasu }, @@ -784,13 +784,13 @@ static PyMethodDef Pygmpy_methods [] = { "mpz_rrandomb", GMPy_MPZ_rrandomb_Function, METH_VARARGS, GMPy_doc_mpz_rrandomb_function }, { "mpz_urandomb", GMPy_MPZ_urandomb_Function, METH_VARARGS, GMPy_doc_mpz_urandomb_function }, { "mul", GMPy_Context_Mul, METH_VARARGS, GMPy_doc_function_mul }, - { "multi_fac", GMPy_MPZ_Function_MultiFac, METH_VARARGS, GMPy_doc_mpz_function_multi_fac }, + { "multi_fac", (PyCFunction)GMPy_MPZ_Function_MultiFac, METH_FASTCALL, GMPy_doc_mpz_function_multi_fac }, { "next_prime", GMPy_MPZ_Function_NextPrime, METH_O, GMPy_doc_mpz_function_next_prime }, #if (__GNU_MP_VERSION > 6) || (__GNU_MP_VERSION == 6 && __GNU_MP_VERSION_MINOR >= 3) { "prev_prime", GMPy_MPZ_Function_PrevPrime, METH_O, GMPy_doc_mpz_function_prev_prime }, #endif { "numer", GMPy_MPQ_Function_Numer, METH_O, GMPy_doc_mpq_function_numer }, - { "num_digits", GMPy_MPZ_Function_NumDigits, METH_VARARGS, GMPy_doc_mpz_function_num_digits }, + { "num_digits", (PyCFunction)GMPy_MPZ_Function_NumDigits, METH_FASTCALL, GMPy_doc_mpz_function_num_digits }, { "pack", GMPy_MPZ_pack, METH_VARARGS, doc_pack }, { "popcount", GMPy_MPZ_popcount, METH_O, doc_popcount }, { "powmod", GMPy_Integer_PowMod, METH_VARARGS, GMPy_doc_integer_powmod }, @@ -799,7 +799,7 @@ static PyMethodDef Pygmpy_methods [] = { "powmod_sec", GMPy_Integer_PowMod_Sec, METH_VARARGS, GMPy_doc_integer_powmod_sec }, { "primorial", GMPy_MPZ_Function_Primorial, METH_O, GMPy_doc_mpz_function_primorial }, { "qdiv", GMPy_MPQ_Function_Qdiv, METH_VARARGS, GMPy_doc_function_qdiv }, - { "remove", GMPy_MPZ_Function_Remove, METH_VARARGS, GMPy_doc_mpz_function_remove }, + { "remove", (PyCFunction)GMPy_MPZ_Function_Remove, METH_FASTCALL, GMPy_doc_mpz_function_remove }, { "random_state", GMPy_RandomState_Factory, METH_VARARGS, GMPy_doc_random_state_factory }, { "sign", GMPy_Context_Sign, METH_O, GMPy_doc_function_sign }, { "square", GMPy_Context_Square, METH_O, GMPy_doc_function_square }, @@ -814,8 +814,8 @@ static PyMethodDef Pygmpy_methods [] = { "unpack", GMPy_MPZ_unpack, METH_VARARGS, doc_unpack }, { "version", GMPy_get_version, METH_NOARGS, GMPy_doc_version }, { "xbit_mask", GMPy_XMPZ_Function_XbitMask, METH_O, GMPy_doc_xmpz_function_xbit_mask }, - { "_mpmath_normalize", (PyCFunction)(void(*)(void))Pympz_mpmath_normalize_fast, METH_FASTCALL, doc_mpmath_normalizeg }, - { "_mpmath_create", (PyCFunction)(void(*)(void))Pympz_mpmath_create_fast, METH_FASTCALL, doc_mpmath_create }, + { "_mpmath_normalize", (PyCFunction)Pympz_mpmath_normalize_fast, METH_FASTCALL, doc_mpmath_normalizeg }, + { "_mpmath_create", (PyCFunction)Pympz_mpmath_create_fast, METH_FASTCALL, doc_mpmath_create }, { "acos", GMPy_Context_Acos, METH_O, GMPy_doc_function_acos }, { "acosh", GMPy_Context_Acosh, METH_O, GMPy_doc_function_acosh }, diff --git a/src/gmpy2.h b/src/gmpy2.h index ff2ace17..03a8443d 100644 --- a/src/gmpy2.h +++ b/src/gmpy2.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * @@ -71,10 +71,6 @@ extern "C" { # error "GMPY2 requires Python 3.7 or later." #endif -#if PY_VERSION_HEX < 0x03080000 -# define PyVectorcall_NARGS(n) (n) -#endif - /* Include headers for GMP, MPFR, and MPC. */ #include diff --git a/src/gmpy2_abs.c b/src/gmpy2_abs.c index a9c51e4e..566370a4 100644 --- a/src/gmpy2_abs.c +++ b/src/gmpy2_abs.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_abs.h b/src/gmpy2_abs.h index 36918770..d7957ddc 100644 --- a/src/gmpy2_abs.h +++ b/src/gmpy2_abs.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_add.c b/src/gmpy2_add.c index 53a81fb4..b74c1ec3 100644 --- a/src/gmpy2_add.c +++ b/src/gmpy2_add.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_add.h b/src/gmpy2_add.h index 062187de..bee4f127 100644 --- a/src/gmpy2_add.h +++ b/src/gmpy2_add.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_binary.c b/src/gmpy2_binary.c index 9b043bbc..d46e2d22 100644 --- a/src/gmpy2_binary.c +++ b/src/gmpy2_binary.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_binary.h b/src/gmpy2_binary.h index be342a1f..624f5def 100644 --- a/src/gmpy2_binary.h +++ b/src/gmpy2_binary.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_cache.c b/src/gmpy2_cache.c index 65169c31..8df8349b 100644 --- a/src/gmpy2_cache.c +++ b/src/gmpy2_cache.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_cache.h b/src/gmpy2_cache.h index 16d77e11..028a0677 100644 --- a/src/gmpy2_cache.h +++ b/src/gmpy2_cache.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_cmp.c b/src/gmpy2_cmp.c index dd595b4d..01039a9d 100644 --- a/src/gmpy2_cmp.c +++ b/src/gmpy2_cmp.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_cmp.h b/src/gmpy2_cmp.h index ac6b19ed..5d18214d 100644 --- a/src/gmpy2_cmp.h +++ b/src/gmpy2_cmp.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_const.c b/src/gmpy2_const.c index e650ce92..348026ac 100644 --- a/src/gmpy2_const.c +++ b/src/gmpy2_const.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_const.h b/src/gmpy2_const.h index 22b25a53..28554a7b 100644 --- a/src/gmpy2_const.h +++ b/src/gmpy2_const.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_context.c b/src/gmpy2_context.c index d5aa844d..f33b8069 100644 --- a/src/gmpy2_context.c +++ b/src/gmpy2_context.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_context.h b/src/gmpy2_context.h index d70fb791..6fa82c20 100644 --- a/src/gmpy2_context.h +++ b/src/gmpy2_context.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_convert.c b/src/gmpy2_convert.c index 535e9589..79059aab 100644 --- a/src/gmpy2_convert.c +++ b/src/gmpy2_convert.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_convert.h b/src/gmpy2_convert.h index 061e82cd..40e59e05 100644 --- a/src/gmpy2_convert.h +++ b/src/gmpy2_convert.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * @@ -154,44 +154,6 @@ extern "C" { # define _PyLong_DigitCount(obj) (_PyLong_IsNegative(obj)? -Py_SIZE(obj):Py_SIZE(obj)) #endif -#if PY_VERSION_HEX >= 0x030D0000 - -#define MAX_LONG_DIGITS \ - ((PY_SSIZE_T_MAX - offsetof(PyLongObject, long_value.ob_digit))/sizeof(digit)) - -PyLongObject * -_PyLong_New(Py_ssize_t size) -{ - assert(size >= 0); - PyLongObject *result; - if (size > (Py_ssize_t)MAX_LONG_DIGITS) { - PyErr_SetString(PyExc_OverflowError, - "too many digits in integer"); - return NULL; - } - /* Fast operations for single digit integers (including zero) - * assume that there is always at least one digit present. */ - Py_ssize_t ndigits = size ? size : 1; - /* Number of bytes needed is: offsetof(PyLongObject, ob_digit) + - sizeof(digit)*size. Previous incarnations of this code used - sizeof() instead of the offsetof, but this risks being - incorrect in the presence of padding between the header - and the digits. */ - result = PyObject_Malloc(offsetof(PyLongObject, long_value.ob_digit) + - ndigits*sizeof(digit)); - if (!result) { - PyErr_NoMemory(); - return NULL; - } - _PyLong_SetSignAndDigitCount(result, size != 0, size); - PyObject_Init((PyObject*)result, &PyLong_Type); - /* The digit has to be initialized explicitly to avoid - * use-of-uninitialized-value. */ - result->long_value.ob_digit[0] = 0; - return result; -} -#endif - /* Since the macros are used in gmpy2's codebase, these functions are skipped * until they are needed for the C API in the future. */ diff --git a/src/gmpy2_convert_gmp.c b/src/gmpy2_convert_gmp.c index 72a5bda0..7321affd 100644 --- a/src/gmpy2_convert_gmp.c +++ b/src/gmpy2_convert_gmp.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * * * GMPY2 is free software: you can redistribute it and/or modify it under * diff --git a/src/gmpy2_convert_gmp.h b/src/gmpy2_convert_gmp.h index b7ec57ab..8d73d060 100644 --- a/src/gmpy2_convert_gmp.h +++ b/src/gmpy2_convert_gmp.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_convert_mpc.c b/src/gmpy2_convert_mpc.c index 308ead6a..ebd27b27 100644 --- a/src/gmpy2_convert_mpc.c +++ b/src/gmpy2_convert_mpc.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_convert_mpc.h b/src/gmpy2_convert_mpc.h index e5a9001e..fca78adf 100644 --- a/src/gmpy2_convert_mpc.h +++ b/src/gmpy2_convert_mpc.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_convert_mpfr.c b/src/gmpy2_convert_mpfr.c index e76d1f77..43176387 100644 --- a/src/gmpy2_convert_mpfr.c +++ b/src/gmpy2_convert_mpfr.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_convert_mpfr.h b/src/gmpy2_convert_mpfr.h index c910ca54..9f4d2f89 100644 --- a/src/gmpy2_convert_mpfr.h +++ b/src/gmpy2_convert_mpfr.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_convert_utils.c b/src/gmpy2_convert_utils.c index f711d82b..824eb174 100644 --- a/src/gmpy2_convert_utils.c +++ b/src/gmpy2_convert_utils.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_convert_utils.h b/src/gmpy2_convert_utils.h index f3bad553..23d12955 100644 --- a/src/gmpy2_convert_utils.h +++ b/src/gmpy2_convert_utils.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_divmod.c b/src/gmpy2_divmod.c index 0c98ce56..2792602f 100644 --- a/src/gmpy2_divmod.c +++ b/src/gmpy2_divmod.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_divmod.h b/src/gmpy2_divmod.h index 9cc46927..6f665683 100644 --- a/src/gmpy2_divmod.h +++ b/src/gmpy2_divmod.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_floordiv.c b/src/gmpy2_floordiv.c index 503e2862..9988976f 100644 --- a/src/gmpy2_floordiv.c +++ b/src/gmpy2_floordiv.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_floordiv.h b/src/gmpy2_floordiv.h index f10fa025..fd04d695 100644 --- a/src/gmpy2_floordiv.h +++ b/src/gmpy2_floordiv.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_format.c b/src/gmpy2_format.c index c99640b4..3c9565eb 100644 --- a/src/gmpy2_format.c +++ b/src/gmpy2_format.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_format.h b/src/gmpy2_format.h index 2715ca53..47ad82bb 100644 --- a/src/gmpy2_format.h +++ b/src/gmpy2_format.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_fused.c b/src/gmpy2_fused.c index 8a710117..3c737e00 100644 --- a/src/gmpy2_fused.c +++ b/src/gmpy2_fused.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_fused.h b/src/gmpy2_fused.h index bcd5f8b3..ad3ddc66 100644 --- a/src/gmpy2_fused.h +++ b/src/gmpy2_fused.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_hash.c b/src/gmpy2_hash.c index 5ed6af23..d8d045cd 100644 --- a/src/gmpy2_hash.c +++ b/src/gmpy2_hash.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * @@ -24,11 +24,6 @@ * License along with GMPY2; if not, see * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#if PY_VERSION_HEX >= 0x030D0000 -# define Py_BUILD_CORE -# include -#endif - static Py_hash_t GMPy_MPZ_Hash_Slot(MPZ_Object *self) { diff --git a/src/gmpy2_hash.h b/src/gmpy2_hash.h index 02a1e164..510e192b 100644 --- a/src/gmpy2_hash.h +++ b/src/gmpy2_hash.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_macros.h b/src/gmpy2_macros.h index 5fb441b9..5e5a0268 100644 --- a/src/gmpy2_macros.h +++ b/src/gmpy2_macros.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_math.c b/src/gmpy2_math.c index a4c01485..deac8c37 100644 --- a/src/gmpy2_math.c +++ b/src/gmpy2_math.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_math.h b/src/gmpy2_math.h index 999288bb..89530fb6 100644 --- a/src/gmpy2_math.h +++ b/src/gmpy2_math.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_minus.c b/src/gmpy2_minus.c index 2ed02b2e..805c443f 100644 --- a/src/gmpy2_minus.c +++ b/src/gmpy2_minus.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_minus.h b/src/gmpy2_minus.h index ea8fee2d..4fb98fcf 100644 --- a/src/gmpy2_minus.h +++ b/src/gmpy2_minus.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_misc.c b/src/gmpy2_misc.c index e383290d..658f6454 100644 --- a/src/gmpy2_misc.c +++ b/src/gmpy2_misc.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_misc.h b/src/gmpy2_misc.h index 0458dacf..3001fdf6 100644 --- a/src/gmpy2_misc.h +++ b/src/gmpy2_misc.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mod.c b/src/gmpy2_mod.c index 2a65469a..7b17fff1 100644 --- a/src/gmpy2_mod.c +++ b/src/gmpy2_mod.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mod.h b/src/gmpy2_mod.h index bba58f4d..943c8d67 100644 --- a/src/gmpy2_mod.h +++ b/src/gmpy2_mod.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpc.c b/src/gmpy2_mpc.c index a73fb6ae..790fab64 100644 --- a/src/gmpy2_mpc.c +++ b/src/gmpy2_mpc.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpc.h b/src/gmpy2_mpc.h index d469596a..bc3d4d58 100644 --- a/src/gmpy2_mpc.h +++ b/src/gmpy2_mpc.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpc_misc.c b/src/gmpy2_mpc_misc.c index 74644c6b..5e30c454 100644 --- a/src/gmpy2_mpc_misc.c +++ b/src/gmpy2_mpc_misc.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpc_misc.h b/src/gmpy2_mpc_misc.h index 7bdd0abc..47f7956f 100644 --- a/src/gmpy2_mpc_misc.h +++ b/src/gmpy2_mpc_misc.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpfr.c b/src/gmpy2_mpfr.c index ec05008e..ec4e4574 100644 --- a/src/gmpy2_mpfr.c +++ b/src/gmpy2_mpfr.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpfr.h b/src/gmpy2_mpfr.h index 0d4c6e13..b51ed5fa 100644 --- a/src/gmpy2_mpfr.h +++ b/src/gmpy2_mpfr.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpfr_misc.c b/src/gmpy2_mpfr_misc.c index ccdfa8a0..94aa7b9b 100644 --- a/src/gmpy2_mpfr_misc.c +++ b/src/gmpy2_mpfr_misc.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpfr_misc.h b/src/gmpy2_mpfr_misc.h index 04ecbed7..236ae497 100644 --- a/src/gmpy2_mpfr_misc.h +++ b/src/gmpy2_mpfr_misc.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpmath.c b/src/gmpy2_mpmath.c index d8f2823f..7258ff69 100644 --- a/src/gmpy2_mpmath.c +++ b/src/gmpy2_mpmath.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * @@ -94,7 +94,7 @@ PyDoc_STRVAR(doc_mpmath_normalizeg, "_mpmath_normalize(...): helper function for mpmath."); static PyObject * -Pympz_mpmath_normalize_fast(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +Pympz_mpmath_normalize_fast(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { long sign = 0; long carry = 0; @@ -103,7 +103,7 @@ Pympz_mpmath_normalize_fast(PyObject *self, PyObject *const *args, Py_ssize_t na MPZ_Object *man = NULL, *upper = NULL, *lower = NULL; Py_UCS4 rnd = 0; - if (PyVectorcall_NARGS(nargs) == 6) { + if (nargs == 6) { /* Need better error-checking here. Under Python 3.0, overflow into C-long is possible. */ sign = mpmath_get_sign(args[0]); @@ -270,24 +270,21 @@ PyDoc_STRVAR(doc_mpmath_create, "_mpmath_create(...): helper function for mpmath."); static PyObject * -Pympz_mpmath_create_fast(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +Pympz_mpmath_create_fast(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { long sign, carry = 0; mp_bitcnt_t zbits, bc = 0, prec = 0, shift = 0; - Py_ssize_t n = 0; PyObject *exp = NULL, *newexp = NULL, *newexp2 = NULL, *tmp = NULL; MPZ_Object *man = NULL, *upper = NULL, *lower = NULL; Py_UCS4 rnd = (Py_UCS4)'f'; - n = PyVectorcall_NARGS(nargs); - - if (n < 2) { + if (nargs < 2) { TYPE_ERROR("mpmath_create() expects 'mpz','int'[,'int','str'] arguments"); return NULL; } - switch (n) { + switch (nargs) { case 4: rnd = PyString_1Char(args[3]); case 3: diff --git a/src/gmpy2_mpq.c b/src/gmpy2_mpq.c index 186609e9..5b3f8063 100644 --- a/src/gmpy2_mpq.c +++ b/src/gmpy2_mpq.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpq.h b/src/gmpy2_mpq.h index f33ab711..d66d9372 100644 --- a/src/gmpy2_mpq.h +++ b/src/gmpy2_mpq.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpq_misc.c b/src/gmpy2_mpq_misc.c index 4ace75b1..f546aa6f 100644 --- a/src/gmpy2_mpq_misc.c +++ b/src/gmpy2_mpq_misc.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpq_misc.h b/src/gmpy2_mpq_misc.h index 1c6197c9..56959127 100644 --- a/src/gmpy2_mpq_misc.h +++ b/src/gmpy2_mpq_misc.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpz.c b/src/gmpy2_mpz.c index 32cf6b32..5e8067ec 100644 --- a/src/gmpy2_mpz.c +++ b/src/gmpy2_mpz.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * @@ -88,7 +88,7 @@ static PyMethodDef GMPy_MPZ_methods[] = { { "__format__", GMPy_MPZ_Format, METH_VARARGS, GMPy_doc_mpz_format }, { "__ceil__", GMPy_MPZ_Method_Ceil, METH_NOARGS, GMPy_doc_mpz_method_ceil }, { "__floor__", GMPy_MPZ_Method_Floor, METH_NOARGS, GMPy_doc_mpz_method_floor }, - { "__round__", GMPy_MPZ_Method_Round, METH_VARARGS, GMPy_doc_mpz_method_round }, + { "__round__", (PyCFunction)GMPy_MPZ_Method_Round, METH_FASTCALL, GMPy_doc_mpz_method_round }, { "__sizeof__", GMPy_MPZ_Method_SizeOf, METH_NOARGS, GMPy_doc_mpz_method_sizeof }, { "__trunc__", GMPy_MPZ_Method_Trunc, METH_NOARGS, GMPy_doc_mpz_method_trunc }, { "bit_clear", GMPy_MPZ_bit_clear_method, METH_O, doc_bit_clear_method }, @@ -106,10 +106,10 @@ static PyMethodDef GMPy_MPZ_methods[] = { { "is_even", GMPy_MPZ_Method_IsEven, METH_NOARGS, GMPy_doc_mpz_method_is_even }, { "is_odd", GMPy_MPZ_Method_IsOdd, METH_NOARGS, GMPy_doc_mpz_method_is_odd }, { "is_power", GMPy_MPZ_Method_IsPower, METH_NOARGS, GMPy_doc_mpz_method_is_power }, - { "is_prime", GMPy_MPZ_Method_IsPrime, METH_VARARGS, GMPy_doc_mpz_method_is_prime }, + { "is_prime", (PyCFunction)GMPy_MPZ_Method_IsPrime, METH_FASTCALL, GMPy_doc_mpz_method_is_prime }, { "is_probab_prime", (PyCFunction)GMPy_MPZ_Method_IsProbabPrime, METH_FASTCALL, GMPy_doc_mpz_method_is_probab_prime }, { "is_square", GMPy_MPZ_Method_IsSquare, METH_NOARGS, GMPy_doc_mpz_method_is_square }, - { "num_digits", GMPy_MPZ_Method_NumDigits, METH_VARARGS, GMPy_doc_mpz_method_num_digits }, + { "num_digits", (PyCFunction)GMPy_MPZ_Method_NumDigits, METH_FASTCALL, GMPy_doc_mpz_method_num_digits }, { "as_integer_ratio", GMPy_MPZ_Method_As_Integer_Ratio, METH_NOARGS, GMPy_doc_mpz_method_as_integer_ratio }, { "to_bytes", (PyCFunction)GMPy_MPZ_Method_To_Bytes, METH_FASTCALL | METH_KEYWORDS, GMPy_doc_mpz_method_to_bytes }, { "from_bytes", (PyCFunction)GMPy_MPZ_Method_From_Bytes, METH_FASTCALL | METH_KEYWORDS | METH_CLASS, GMPy_doc_mpz_method_from_bytes }, diff --git a/src/gmpy2_mpz.h b/src/gmpy2_mpz.h index 423a6dde..e55623fd 100644 --- a/src/gmpy2_mpz.h +++ b/src/gmpy2_mpz.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpz_bitops.c b/src/gmpy2_mpz_bitops.c index 610892c9..c18e6098 100644 --- a/src/gmpy2_mpz_bitops.c +++ b/src/gmpy2_mpz_bitops.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpz_bitops.h b/src/gmpy2_mpz_bitops.h index b70427cb..b18c6837 100644 --- a/src/gmpy2_mpz_bitops.h +++ b/src/gmpy2_mpz_bitops.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpz_divmod.c b/src/gmpy2_mpz_divmod.c index 3be7bd2d..3e18ac30 100644 --- a/src/gmpy2_mpz_divmod.c +++ b/src/gmpy2_mpz_divmod.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpz_divmod.h b/src/gmpy2_mpz_divmod.h index b7539dec..8153cbe7 100644 --- a/src/gmpy2_mpz_divmod.h +++ b/src/gmpy2_mpz_divmod.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpz_divmod2exp.c b/src/gmpy2_mpz_divmod2exp.c index 13880e52..968996a5 100644 --- a/src/gmpy2_mpz_divmod2exp.c +++ b/src/gmpy2_mpz_divmod2exp.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpz_divmod2exp.h b/src/gmpy2_mpz_divmod2exp.h index 7984c3bf..99ad732b 100644 --- a/src/gmpy2_mpz_divmod2exp.h +++ b/src/gmpy2_mpz_divmod2exp.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpz_misc.c b/src/gmpy2_mpz_misc.c index 571fee9e..8c9fd497 100644 --- a/src/gmpy2_mpz_misc.c +++ b/src/gmpy2_mpz_misc.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * @@ -38,13 +38,14 @@ PyDoc_STRVAR(GMPy_doc_mpz_function_num_digits, "value returned may be 1 too large."); static PyObject * -GMPy_MPZ_Method_NumDigits(PyObject *self, PyObject *args) +GMPy_MPZ_Method_NumDigits(PyObject *self, PyObject *const *args, + Py_ssize_t nargs) { long base = 10; PyObject *result; - if (PyTuple_GET_SIZE(args) == 1) { - base = PyLong_AsLong(PyTuple_GET_ITEM(args, 0)); + if (nargs == 1) { + base = PyLong_AsLong(args[0]); if (base == -1 && PyErr_Occurred()) { return NULL; } @@ -60,21 +61,20 @@ GMPy_MPZ_Method_NumDigits(PyObject *self, PyObject *args) } static PyObject * -GMPy_MPZ_Function_NumDigits(PyObject *self, PyObject *args) +GMPy_MPZ_Function_NumDigits(PyObject *self, PyObject *const *args, + Py_ssize_t nargs) { long base = 10; - Py_ssize_t argc; MPZ_Object *temp; PyObject *result; - argc = PyTuple_GET_SIZE(args); - if (argc == 0 || argc > 2) { + if (nargs == 0 || nargs > 2) { TYPE_ERROR("num_digits() requires 'mpz',['int'] arguments"); return NULL; } - if (argc == 2) { - base = PyLong_AsLong(PyTuple_GET_ITEM(args, 1)); + if (nargs == 2) { + base = PyLong_AsLong(args[1]); if (base == -1 && PyErr_Occurred()) { return NULL; } @@ -85,7 +85,7 @@ GMPy_MPZ_Function_NumDigits(PyObject *self, PyObject *args) return NULL; } - if (!(temp = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 0), NULL))) { + if (!(temp = GMPy_MPZ_From_Integer(args[0], NULL))) { return NULL; } @@ -100,22 +100,20 @@ PyDoc_STRVAR(GMPy_doc_mpz_function_iroot, "iff the root is exact. x >= 0. n > 0."); static PyObject * -GMPy_MPZ_Function_Iroot(PyObject *self, PyObject *args) +GMPy_MPZ_Function_Iroot(PyObject *self, PyObject *const *args, + Py_ssize_t nargs) { unsigned long n; int exact, is_signed = 0; MPZ_Object *root = NULL, *tempx = NULL; PyObject *result = NULL; - if ((PyTuple_GET_SIZE(args) != 2) || - ((!IS_INTEGER(PyTuple_GET_ITEM(args, 0))) || - (!IS_INTEGER(PyTuple_GET_ITEM(args, 1))))) { - + if (nargs != 2 || !IS_INTEGER(args[0]) || !IS_INTEGER(args[1])) { TYPE_ERROR("iroot() requires 'int','int' arguments"); return NULL; } - n = (unsigned long)GMPy_Integer_AsUnsignedLongOrLong(PyTuple_GET_ITEM(args, 1), &is_signed); + n = (unsigned long)GMPy_Integer_AsUnsignedLongOrLong(args[1], &is_signed); if ((n == (unsigned long)(-1)) && PyErr_Occurred()) { return NULL; } @@ -124,7 +122,7 @@ GMPy_MPZ_Function_Iroot(PyObject *self, PyObject *args) return NULL; } - if (!(tempx = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 0), NULL))) { + if (!(tempx = GMPy_MPZ_From_Integer(args[0], NULL))) { /* LCOV_EXCL_START */ return NULL; /* LCOV_EXCL_STOP */ @@ -161,27 +159,25 @@ PyDoc_STRVAR(GMPy_doc_mpz_function_iroot_rem, "root of x and x=y**n + r. x >= 0. n > 0."); static PyObject * -GMPy_MPZ_Function_IrootRem(PyObject *self, PyObject *args) +GMPy_MPZ_Function_IrootRem(PyObject *self, PyObject *const *args, + Py_ssize_t nargs) { unsigned long n; MPZ_Object *root = NULL, *rem = NULL, *tempx = NULL; PyObject *result = NULL; - if ((PyTuple_GET_SIZE(args) != 2) || - ((!IS_INTEGER(PyTuple_GET_ITEM(args, 0))) || - (!IS_INTEGER(PyTuple_GET_ITEM(args, 1))))) { - + if (nargs != 2 || !IS_INTEGER(args[0]) || !IS_INTEGER(args[1])) { TYPE_ERROR("iroot_rem() requires 'int','int' arguments"); return NULL; } - n = GMPy_Integer_AsUnsignedLong(PyTuple_GET_ITEM(args, 1)); + n = GMPy_Integer_AsUnsignedLong(args[1]); if ((n == 0) || ((n == (unsigned long)(-1)) && PyErr_Occurred())) { VALUE_ERROR("n must be > 0"); return NULL; } - if (!(tempx = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 0), NULL))) { + if (!(tempx = GMPy_MPZ_From_Integer(args[0], NULL))) { /* LCOV_EXCL_START */ return NULL; /* LCOV_EXCL_STOP */ @@ -244,18 +240,19 @@ GMPy_MPZ_Method_Trunc(PyObject *self, PyObject *other) PyDoc_STRVAR(GMPy_doc_mpz_method_round, "Round an mpz to power of 10."); static PyObject * -GMPy_MPZ_Method_Round(PyObject *self, PyObject *args) +GMPy_MPZ_Method_Round(PyObject *self, PyObject *const *args, + Py_ssize_t nargs) { Py_ssize_t round_digits; MPZ_Object *result; mpz_t temp, rem; - if (PyTuple_GET_SIZE(args) == 0) { + if (nargs == 0) { Py_INCREF(self); return self; } - round_digits = GMPy_Integer_AsSsize_t(PyTuple_GET_ITEM(args, 0)); + round_digits = GMPy_Integer_AsSsize_t(args[0]); if (round_digits == -1 && PyErr_Occurred()) { TYPE_ERROR("__round__() requires 'int' argument"); return NULL; @@ -386,7 +383,8 @@ PyDoc_STRVAR(GMPy_doc_mpz_function_gcdext, "and g == a*s + b*t."); static PyObject * -GMPy_MPZ_Function_GCDext(PyObject *self, PyObject *args) +GMPy_MPZ_Function_GCDext(PyObject *self, PyObject * const *args, + Py_ssize_t nargs) { PyObject *arg0, *arg1, *result = NULL; MPZ_Object *g = NULL, *s = NULL, *t = NULL, *tempa = NULL, *tempb = NULL; @@ -394,7 +392,7 @@ GMPy_MPZ_Function_GCDext(PyObject *self, PyObject *args) CHECK_CONTEXT(context); - if(PyTuple_GET_SIZE(args) != 2) { + if(nargs != 2) { TYPE_ERROR("gcdext() requires 'mpz','mpz' arguments"); return NULL; } @@ -413,8 +411,8 @@ GMPy_MPZ_Function_GCDext(PyObject *self, PyObject *args) /* LCOV_EXCL_STOP */ } - arg0 = PyTuple_GET_ITEM(args, 0); - arg1 = PyTuple_GET_ITEM(args, 1); + arg0 = args[0]; + arg1 = args[1]; if (MPZ_Check(arg0) && MPZ_Check(arg1)) { GMPY_MAYBE_BEGIN_ALLOW_THREADS(context); @@ -452,7 +450,8 @@ PyDoc_STRVAR(GMPy_doc_mpz_function_divm, "exception if no such value x exists."); static PyObject * -GMPy_MPZ_Function_Divm(PyObject *self, PyObject *args) +GMPy_MPZ_Function_Divm(PyObject *self, PyObject * const *args, + Py_ssize_t nargs) { MPZ_Object *result = NULL, *num = NULL, *den = NULL, *mod = NULL; mpz_t numz, denz, modz, gcdz; @@ -461,7 +460,7 @@ GMPy_MPZ_Function_Divm(PyObject *self, PyObject *args) CHECK_CONTEXT(context); - if (PyTuple_GET_SIZE(args) != 3) { + if (nargs != 3) { TYPE_ERROR("divm() requires 'mpz','mpz','mpz' arguments"); return NULL; } @@ -472,9 +471,9 @@ GMPy_MPZ_Function_Divm(PyObject *self, PyObject *args) /* LCOV_EXCL_STOP */ } - if (!(num = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 0), NULL)) || - !(den = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 1), NULL)) || - !(mod = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 2), NULL))) { + if (!(num = GMPy_MPZ_From_Integer(args[0], NULL)) || + !(den = GMPy_MPZ_From_Integer(args[1], NULL)) || + !(mod = GMPy_MPZ_From_Integer(args[2], NULL))) { TYPE_ERROR("divm() requires 'mpz','mpz','mpz' arguments"); Py_XDECREF((PyObject*)num); @@ -606,22 +605,23 @@ PyDoc_STRVAR(GMPy_doc_mpz_function_multi_fac, "factorial is defined as n*(n-m)*(n-2m)..."); static PyObject * -GMPy_MPZ_Function_MultiFac(PyObject *self, PyObject *args) +GMPy_MPZ_Function_MultiFac(PyObject *self, PyObject *const *args, + Py_ssize_t nargs) { MPZ_Object *result = NULL; unsigned long n, m; - if (PyTuple_GET_SIZE(args) != 2) { + if (nargs != 2) { TYPE_ERROR("multi_fac() requires 2 integer arguments"); return NULL; } - n = GMPy_Integer_AsUnsignedLong(PyTuple_GET_ITEM(args, 0)); + n = GMPy_Integer_AsUnsignedLong(args[0]); if (n == (unsigned long)(-1) && PyErr_Occurred()) { return NULL; } - m = GMPy_Integer_AsUnsignedLong(PyTuple_GET_ITEM(args, 1)); + m = GMPy_Integer_AsUnsignedLong(args[1]); if (m == (unsigned long)(-1) && PyErr_Occurred()) { return NULL; } @@ -751,12 +751,13 @@ PyDoc_STRVAR(GMPy_doc_mpz_function_comb, "time'. k >= 0. Same as bincoef(n, k)"); static PyObject * -GMPy_MPZ_Function_Bincoef(PyObject *self, PyObject *args) +GMPy_MPZ_Function_Bincoef(PyObject *self, PyObject * const *args, + Py_ssize_t nargs) { MPZ_Object *result = NULL, *tempx; unsigned long n, k; - if (PyTuple_GET_SIZE(args) != 2) { + if (nargs != 2) { TYPE_ERROR("bincoef() requires two integer arguments"); return NULL; } @@ -767,13 +768,13 @@ GMPy_MPZ_Function_Bincoef(PyObject *self, PyObject *args) /* LCOV_EXCL_STOP */ } - k = GMPy_Integer_AsUnsignedLong(PyTuple_GET_ITEM(args, 1)); + k = GMPy_Integer_AsUnsignedLong(args[1]); if (k == (unsigned long)(-1) && PyErr_Occurred()) { Py_DECREF((PyObject*)result); return NULL; } - n = GMPy_Integer_AsUnsignedLong(PyTuple_GET_ITEM(args, 0)); + n = GMPy_Integer_AsUnsignedLong(args[0]); if (n == (unsigned long)(-1) && PyErr_Occurred()) { /* Since we plan to skip the else clause and continue, * we need to clear the error since we aren't acting on it. @@ -786,7 +787,7 @@ GMPy_MPZ_Function_Bincoef(PyObject *self, PyObject *args) return (PyObject*)result; } - if (!(tempx = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 0), NULL))) { + if (!(tempx = GMPy_MPZ_From_Integer(args[0], NULL))) { Py_DECREF((PyObject*)result); return NULL; } @@ -878,13 +879,14 @@ PyDoc_STRVAR(GMPy_doc_mpz_function_remove, "possible. m is the multiplicity f in x. f > 1."); static PyObject * -GMPy_MPZ_Function_Remove(PyObject *self, PyObject *args) +GMPy_MPZ_Function_Remove(PyObject *self, PyObject * const *args, + Py_ssize_t nargs) { MPZ_Object *result = NULL, *tempx = NULL, *tempf = NULL; PyObject *x, *f; size_t multiplicity; - if (PyTuple_GET_SIZE(args) != 2) { + if (nargs != 2) { TYPE_ERROR("remove() requires 'mpz','mpz' arguments"); return NULL; } @@ -895,8 +897,8 @@ GMPy_MPZ_Function_Remove(PyObject *self, PyObject *args) /* LCOV_EXCL_STOP */ } - x = PyTuple_GET_ITEM(args, 0); - f = PyTuple_GET_ITEM(args, 1); + x = args[0]; + f = args[1]; if (MPZ_Check(x) && MPZ_Check(f)) { if (mpz_cmp_si(MPZ(f), 2) < 0) { @@ -939,13 +941,14 @@ PyDoc_STRVAR(GMPy_doc_mpz_function_invert, "inverse exists."); static PyObject * -GMPy_MPZ_Function_Invert(PyObject *self, PyObject *args) +GMPy_MPZ_Function_Invert(PyObject *self, PyObject * const *args, + Py_ssize_t nargs) { PyObject *x, *y; MPZ_Object *result = NULL, *tempx = NULL, *tempy = NULL; int success; - if (PyTuple_GET_SIZE(args) != 2) { + if (nargs != 2) { TYPE_ERROR("invert() requires 'mpz','mpz' arguments"); return NULL; } @@ -956,8 +959,8 @@ GMPy_MPZ_Function_Invert(PyObject *self, PyObject *args) /* LCOV_EXCL_STOP */ } - x = PyTuple_GET_ITEM(args, 0); - y = PyTuple_GET_ITEM(args, 1); + x = args[0]; + y = args[1]; if (MPZ_Check(x) && MPZ_Check(y)) { if (mpz_sgn(MPZ(y)) == 0) { @@ -1009,12 +1012,13 @@ PyDoc_STRVAR(GMPy_doc_mpz_function_divexact, "division but requires the remainder is zero!"); static PyObject * -GMPy_MPZ_Function_Divexact(PyObject *self, PyObject *args) +GMPy_MPZ_Function_Divexact(PyObject *self, PyObject * const *args, + Py_ssize_t nargs) { PyObject *x, *y; MPZ_Object *result, *tempx= NULL, *tempy = NULL; - if(PyTuple_GET_SIZE(args) != 2) { + if (nargs != 2) { TYPE_ERROR("divexact() requires 'mpz','mpz' arguments"); return NULL; } @@ -1025,8 +1029,8 @@ GMPy_MPZ_Function_Divexact(PyObject *self, PyObject *args) /* LCOV_EXCL_STOP */ } - x = PyTuple_GET_ITEM(args, 0); - y = PyTuple_GET_ITEM(args, 1); + x = args[0]; + y = args[1]; if (MPZ_Check(x) && MPZ_Check(y)) { if (mpz_sgn(MPZ(y)) == 0) { @@ -1112,27 +1116,28 @@ PyDoc_STRVAR(GMPy_doc_mpz_function_is_divisible, "Returns `True` if x is divisible by d, else return `False`."); static PyObject * -GMPy_MPZ_Function_IsDivisible(PyObject *self, PyObject *args) +GMPy_MPZ_Function_IsDivisible(PyObject *self, PyObject * const * args, + Py_ssize_t nargs) { unsigned long temp; int res = 0; MPZ_Object *tempx, *tempd; - if (PyTuple_GET_SIZE(args) != 2) { + if (nargs != 2) { TYPE_ERROR("is_divisible() requires 2 integer arguments"); return NULL; } - if (!(tempx = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 0), NULL))) { + if (!(tempx = GMPy_MPZ_From_Integer(args[0], NULL))) { return NULL; } - temp = GMPy_Integer_AsUnsignedLong(PyTuple_GET_ITEM(args, 1)); + temp = GMPy_Integer_AsUnsignedLong(args[1]); if (temp == (unsigned long)-1 && PyErr_Occurred()) { PyErr_Clear(); /* Implement mpz_divisible_p here. */ - if (!(tempd = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 1), NULL))) { + if (!(tempd = GMPy_MPZ_From_Integer(args[1], NULL))) { TYPE_ERROR("is_divisible() requires 2 integer arguments"); Py_DECREF((PyObject*)tempx); return NULL; @@ -1194,19 +1199,20 @@ PyDoc_STRVAR(GMPy_doc_mpz_function_is_congruent, "Returns `True` if x is congruent to y modulo m, else return `False`."); static PyObject * -GMPy_MPZ_Function_IsCongruent(PyObject *self, PyObject *args) +GMPy_MPZ_Function_IsCongruent(PyObject *self, PyObject * const *args, + Py_ssize_t nargs) { int res; MPZ_Object *tempx = NULL, *tempy = NULL, *tempm = NULL; - if (PyTuple_GET_SIZE(args) != 3) { + if (nargs != 3) { TYPE_ERROR("is_congruent() requires 3 integer arguments"); return NULL; } - if (!(tempx = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 0), NULL)) || - !(tempy = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 1), NULL)) || - !(tempm = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 2), NULL))) { + if (!(tempx = GMPy_MPZ_From_Integer(args[0], NULL)) || + !(tempy = GMPy_MPZ_From_Integer(args[1], NULL)) || + !(tempm = GMPy_MPZ_From_Integer(args[2], NULL))) { Py_XDECREF((PyObject*)tempx); Py_XDECREF((PyObject*)tempy); @@ -1315,22 +1321,20 @@ PyDoc_STRVAR(GMPy_doc_mpz_function_is_prime, "to n Miller-Rabin tests are performed."); static PyObject * -GMPy_MPZ_Function_IsPrime(PyObject *self, PyObject *args) +GMPy_MPZ_Function_IsPrime(PyObject *self, PyObject * const *args, + Py_ssize_t nargs) { int i; unsigned long reps = 25; MPZ_Object* tempx; - Py_ssize_t argc; - - argc = PyTuple_GET_SIZE(args); - if (argc == 0 || argc > 2) { + if (nargs == 0 || nargs > 2) { TYPE_ERROR("is_prime() requires 'mpz'[,'int'] arguments"); return NULL; } - if (PyTuple_GET_SIZE(args) == 2) { - reps = GMPy_Integer_AsUnsignedLong(PyTuple_GET_ITEM(args, 1)); + if (nargs == 2) { + reps = GMPy_Integer_AsUnsignedLong(args[1]); if (reps == (unsigned long)(-1) && PyErr_Occurred()) { return NULL; } @@ -1340,7 +1344,7 @@ GMPy_MPZ_Function_IsPrime(PyObject *self, PyObject *args) } } - if (!(tempx = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 0), NULL))) { + if (!(tempx = GMPy_MPZ_From_Integer(args[0], NULL))) { return NULL; } @@ -1365,21 +1369,19 @@ PyDoc_STRVAR(GMPy_doc_mpz_method_is_prime, "to n Miller-Rabin tests are performed."); static PyObject * -GMPy_MPZ_Method_IsPrime(PyObject *self, PyObject *args) +GMPy_MPZ_Method_IsPrime(PyObject *self, PyObject * const *args, + Py_ssize_t nargs) { int i; unsigned long reps = 25; - Py_ssize_t argc; - argc = PyTuple_GET_SIZE(args); - - if (argc > 1) { + if (nargs > 1) { TYPE_ERROR("is_prime() takes at most 1 argument"); return NULL; } - if (PyTuple_GET_SIZE(args) == 1) { - reps = GMPy_Integer_AsUnsignedLong(PyTuple_GET_ITEM(args, 0)); + if (nargs == 1) { + reps = GMPy_Integer_AsUnsignedLong(args[0]); if (reps == (unsigned long)(-1) && PyErr_Occurred()) { return NULL; } @@ -1553,18 +1555,19 @@ PyDoc_STRVAR(GMPy_doc_mpz_function_jacobi, "Return the Jacobi symbol (x|y). y must be odd and >0."); static PyObject * -GMPy_MPZ_Function_Jacobi(PyObject *self, PyObject *args) +GMPy_MPZ_Function_Jacobi(PyObject *self, PyObject *const *args, + Py_ssize_t nargs) { MPZ_Object *tempx = NULL, *tempy = NULL; long res; - if (PyTuple_GET_SIZE(args) != 2) { + if (nargs != 2) { TYPE_ERROR("jacobi() requires 'mpz','mpz' arguments"); return NULL; } - if (!(tempx = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 0), NULL)) || - !(tempy = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 1), NULL))) { + if (!(tempx = GMPy_MPZ_From_Integer(args[0], NULL)) || + !(tempy = GMPy_MPZ_From_Integer(args[1], NULL))) { Py_XDECREF((PyObject*)tempx); Py_XDECREF((PyObject*)tempy); @@ -1589,18 +1592,19 @@ PyDoc_STRVAR(GMPy_doc_mpz_function_legendre, "Return the Legendre symbol (x|y). y is assumed to be an odd prime."); static PyObject * -GMPy_MPZ_Function_Legendre(PyObject *self, PyObject *args) +GMPy_MPZ_Function_Legendre(PyObject *self, PyObject * const *args, + Py_ssize_t nargs) { MPZ_Object *tempx = NULL, *tempy = NULL; long res; - if (PyTuple_GET_SIZE(args) != 2) { + if (nargs != 2) { TYPE_ERROR("legendre() requires 'mpz','mpz' arguments"); return NULL; } - if (!(tempx = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 0), NULL)) || - !(tempy = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 1), NULL))) { + if (!(tempx = GMPy_MPZ_From_Integer(args[0], NULL)) || + !(tempy = GMPy_MPZ_From_Integer(args[1], NULL))) { Py_XDECREF((PyObject*)tempx); Py_XDECREF((PyObject*)tempy); @@ -1625,18 +1629,19 @@ PyDoc_STRVAR(GMPy_doc_mpz_function_kronecker, "Return the Kronecker-Jacobi symbol (x|y)."); static PyObject * -GMPy_MPZ_Function_Kronecker(PyObject *self, PyObject *args) +GMPy_MPZ_Function_Kronecker(PyObject *self, PyObject * const *args, + Py_ssize_t nargs) { MPZ_Object *tempx = NULL, *tempy = NULL; long res; - if (PyTuple_GET_SIZE(args) != 2) { + if (nargs != 2) { TYPE_ERROR("kronecker() requires 'mpz','mpz' arguments"); return NULL; } - if (!(tempx = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 0), NULL)) || - !(tempy = GMPy_MPZ_From_Integer(PyTuple_GET_ITEM(args, 1), NULL))) { + if (!(tempx = GMPy_MPZ_From_Integer(args[0], NULL)) || + !(tempy = GMPy_MPZ_From_Integer(args[1], NULL))) { Py_XDECREF((PyObject*)tempx); Py_XDECREF((PyObject*)tempy); diff --git a/src/gmpy2_mpz_misc.h b/src/gmpy2_mpz_misc.h index 11811be0..193ed471 100644 --- a/src/gmpy2_mpz_misc.h +++ b/src/gmpy2_mpz_misc.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * @@ -46,54 +46,54 @@ static PyObject * GMPy_MPZ_Method_From_Bytes(PyTypeObject *type, PyObject *const static PyObject * GMPy_MPZ_Method_Ceil(PyObject *self, PyObject *other); static PyObject * GMPy_MPZ_Method_Floor(PyObject *self, PyObject *other); static PyObject * GMPy_MPZ_Method_Trunc(PyObject *self, PyObject *other); -static PyObject * GMPy_MPZ_Method_Round(PyObject *self, PyObject *other); -static PyObject * GMPy_MPZ_Method_NumDigits(PyObject *self, PyObject *args); +static PyObject * GMPy_MPZ_Method_Round(PyObject *self, PyObject *const *args, Py_ssize_t nargs); +static PyObject * GMPy_MPZ_Method_NumDigits(PyObject *self, PyObject *const *args, Py_ssize_t nargs); static Py_ssize_t GMPy_MPZ_Method_Length(MPZ_Object *self); static PyObject * GMPy_MPZ_Method_SubScript(MPZ_Object *self, PyObject *item); static PyObject * GMPy_MPZ_Method_IsSquare(PyObject *self, PyObject *other); static PyObject * GMPy_MPZ_Method_IsDivisible(PyObject *self, PyObject *other); static PyObject * GMPy_MPZ_Method_IsCongruent(PyObject *self, PyObject *const *args, Py_ssize_t nargs); static PyObject * GMPy_MPZ_Method_IsPower(PyObject *self, PyObject *other); -static PyObject * GMPy_MPZ_Method_IsPrime(PyObject *self, PyObject *args); +static PyObject * GMPy_MPZ_Method_IsPrime(PyObject *self, PyObject *const *args, Py_ssize_t nargs); static PyObject * GMPy_MPZ_Method_IsProbabPrime(PyObject *self, PyObject *const *args, Py_ssize_t nargs); static PyObject * GMPy_MPZ_Method_IsEven(PyObject *self, PyObject *other); static PyObject * GMPy_MPZ_Method_IsOdd(PyObject *self, PyObject *other); static PyObject * GMPy_MP_Method_Conjugate(PyObject *self, PyObject *args); -static PyObject * GMPy_MPZ_Function_NumDigits(PyObject *self, PyObject *args); -static PyObject * GMPy_MPZ_Function_Iroot(PyObject *self, PyObject *args); -static PyObject * GMPy_MPZ_Function_IrootRem(PyObject *self, PyObject *args); -static PyObject * GMPy_MPZ_Function_Bincoef(PyObject *self, PyObject *args); +static PyObject * GMPy_MPZ_Function_NumDigits(PyObject *self, PyObject *const *args, Py_ssize_t nargs); +static PyObject * GMPy_MPZ_Function_Iroot(PyObject *self, PyObject *const *args, Py_ssize_t nargs); +static PyObject * GMPy_MPZ_Function_IrootRem(PyObject *self, PyObject *const *args, Py_ssize_t nargs); +static PyObject * GMPy_MPZ_Function_Bincoef(PyObject *self, PyObject *const *args, Py_ssize_t nargs); static PyObject * GMPy_MPZ_Function_GCD(PyObject *self, PyObject * const *args, Py_ssize_t nargs); static PyObject * GMPy_MPZ_Function_LCM(PyObject *self, PyObject * const *args, Py_ssize_t nargs); -static PyObject * GMPy_MPZ_Function_GCDext(PyObject *self, PyObject *args); -static PyObject * GMPy_MPZ_Function_Divm(PyObject *self, PyObject *args); +static PyObject * GMPy_MPZ_Function_GCDext(PyObject *self, PyObject * const *args, Py_ssize_t nargs); +static PyObject * GMPy_MPZ_Function_Divm(PyObject *self, PyObject * const *args, Py_ssize_t nargs); static PyObject * GMPy_MPZ_Function_Fac(PyObject *self, PyObject *other); static PyObject * GMPy_MPZ_Function_Primorial(PyObject *self, PyObject *other); static PyObject * GMPy_MPZ_Function_DoubleFac(PyObject *self, PyObject *other); -static PyObject * GMPy_MPZ_Function_MultiFac(PyObject *self, PyObject *args); +static PyObject * GMPy_MPZ_Function_MultiFac(PyObject *self, PyObject * const *args, Py_ssize_t nargs); static PyObject * GMPy_MPZ_Function_Fib(PyObject *self, PyObject *other); static PyObject * GMPy_MPZ_Function_Fib2(PyObject *self, PyObject *other); static PyObject * GMPy_MPZ_Function_Lucas(PyObject *self, PyObject *other); static PyObject * GMPy_MPZ_Function_Lucas2(PyObject *self, PyObject *other); static PyObject * GMPy_MPZ_Function_Isqrt(PyObject *self, PyObject *other); static PyObject * GMPy_MPZ_Function_IsqrtRem(PyObject *self, PyObject *other); -static PyObject * GMPy_MPZ_Function_Remove(PyObject *self, PyObject *args); -static PyObject * GMPy_MPZ_Function_Invert(PyObject *self, PyObject *args); -static PyObject * GMPy_MPZ_Function_Divexact(PyObject *self, PyObject *args); +static PyObject * GMPy_MPZ_Function_Remove(PyObject *self, PyObject * const *args, Py_ssize_t nargs); +static PyObject * GMPy_MPZ_Function_Invert(PyObject *self, PyObject * const *args, Py_ssize_t nargs); +static PyObject * GMPy_MPZ_Function_Divexact(PyObject *self, PyObject * const *args, Py_ssize_t nargs); static PyObject * GMPy_MPZ_Function_IsSquare(PyObject *self, PyObject *other); -static PyObject * GMPy_MPZ_Function_IsDivisible(PyObject *self, PyObject *args); -static PyObject * GMPy_MPZ_Function_IsCongruent(PyObject *self, PyObject *args); +static PyObject * GMPy_MPZ_Function_IsDivisible(PyObject *self, PyObject * const *args, Py_ssize_t nargs); +static PyObject * GMPy_MPZ_Function_IsCongruent(PyObject *self, PyObject * const *args, Py_ssize_t nargs); static PyObject * GMPy_MPZ_Function_IsPower(PyObject *self, PyObject *other); -static PyObject * GMPy_MPZ_Function_IsPrime(PyObject *self, PyObject *args); +static PyObject * GMPy_MPZ_Function_IsPrime(PyObject *self, PyObject * const *args, Py_ssize_t nargs); static PyObject * GMPy_MPZ_Function_IsProbabPrime(PyObject *self, PyObject *const *args, Py_ssize_t nargs); static PyObject * GMPy_MPZ_Function_NextPrime(PyObject *self, PyObject *other); #if (__GNU_MP_VERSION > 6) || (__GNU_MP_VERSION == 6 && __GNU_MP_VERSION_MINOR >= 3) static PyObject * GMPy_MPZ_Function_PrevPrime(PyObject *self, PyObject *other); #endif -static PyObject * GMPy_MPZ_Function_Jacobi(PyObject *self, PyObject *args); -static PyObject * GMPy_MPZ_Function_Legendre(PyObject *self, PyObject *args); -static PyObject * GMPy_MPZ_Function_Kronecker(PyObject *self, PyObject *args); +static PyObject * GMPy_MPZ_Function_Jacobi(PyObject *self, PyObject * const *args, Py_ssize_t nargs); +static PyObject * GMPy_MPZ_Function_Legendre(PyObject *self, PyObject * const *args, Py_ssize_t nargs); +static PyObject * GMPy_MPZ_Function_Kronecker(PyObject *self, PyObject * const *args, Py_ssize_t nargs); static PyObject * GMPy_MPZ_Function_IsEven(PyObject *self, PyObject *other); static PyObject * GMPy_MPZ_Function_IsOdd(PyObject *self, PyObject *other); diff --git a/src/gmpy2_mpz_pack.c b/src/gmpy2_mpz_pack.c index e6be7cdc..fc1fd0a9 100644 --- a/src/gmpy2_mpz_pack.c +++ b/src/gmpy2_mpz_pack.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mpz_pack.h b/src/gmpy2_mpz_pack.h index a185033e..6aa5d2b5 100644 --- a/src/gmpy2_mpz_pack.h +++ b/src/gmpy2_mpz_pack.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mul.c b/src/gmpy2_mul.c index 20b229dd..790e35be 100644 --- a/src/gmpy2_mul.c +++ b/src/gmpy2_mul.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_mul.h b/src/gmpy2_mul.h index 263e4e94..41d9cbf9 100644 --- a/src/gmpy2_mul.h +++ b/src/gmpy2_mul.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_muldiv_2exp.c b/src/gmpy2_muldiv_2exp.c index 16ee1fc9..937b1d6e 100644 --- a/src/gmpy2_muldiv_2exp.c +++ b/src/gmpy2_muldiv_2exp.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_muldiv_2exp.h b/src/gmpy2_muldiv_2exp.h index af84936b..f49f68c7 100644 --- a/src/gmpy2_muldiv_2exp.h +++ b/src/gmpy2_muldiv_2exp.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_plus.c b/src/gmpy2_plus.c index 8f732923..b2357014 100644 --- a/src/gmpy2_plus.c +++ b/src/gmpy2_plus.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_plus.h b/src/gmpy2_plus.h index 7c9815ce..07fdc5ad 100644 --- a/src/gmpy2_plus.h +++ b/src/gmpy2_plus.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_pow.c b/src/gmpy2_pow.c index c5226d4b..c191bdd6 100644 --- a/src/gmpy2_pow.c +++ b/src/gmpy2_pow.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_pow.h b/src/gmpy2_pow.h index 6f713b7c..9d2ddece 100644 --- a/src/gmpy2_pow.h +++ b/src/gmpy2_pow.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_predicate.c b/src/gmpy2_predicate.c index c7bf40cb..fd7dd898 100644 --- a/src/gmpy2_predicate.c +++ b/src/gmpy2_predicate.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_predicate.h b/src/gmpy2_predicate.h index 99150e76..474fa5b0 100644 --- a/src/gmpy2_predicate.h +++ b/src/gmpy2_predicate.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_random.c b/src/gmpy2_random.c index 5eb12cc2..2134a807 100644 --- a/src/gmpy2_random.c +++ b/src/gmpy2_random.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_random.h b/src/gmpy2_random.h index fef655ed..212bc89c 100644 --- a/src/gmpy2_random.h +++ b/src/gmpy2_random.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_richcompare.c b/src/gmpy2_richcompare.c index af94c69b..046fad1d 100644 --- a/src/gmpy2_richcompare.c +++ b/src/gmpy2_richcompare.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_richcompare.h b/src/gmpy2_richcompare.h index fc6bb53c..aa84657f 100644 --- a/src/gmpy2_richcompare.h +++ b/src/gmpy2_richcompare.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_sign.c b/src/gmpy2_sign.c index 3c5e8549..59a6a65e 100644 --- a/src/gmpy2_sign.c +++ b/src/gmpy2_sign.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_sign.h b/src/gmpy2_sign.h index b6f4c441..feba436c 100644 --- a/src/gmpy2_sign.h +++ b/src/gmpy2_sign.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_square.c b/src/gmpy2_square.c index d81eea41..dbdd9b19 100644 --- a/src/gmpy2_square.c +++ b/src/gmpy2_square.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_square.h b/src/gmpy2_square.h index 8e739838..f38daa25 100644 --- a/src/gmpy2_square.h +++ b/src/gmpy2_square.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_sub.c b/src/gmpy2_sub.c index 16fc3428..5302f935 100644 --- a/src/gmpy2_sub.c +++ b/src/gmpy2_sub.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_sub.h b/src/gmpy2_sub.h index 422e3109..83bd6433 100644 --- a/src/gmpy2_sub.h +++ b/src/gmpy2_sub.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_truediv.c b/src/gmpy2_truediv.c index f581d48b..e0dadbaf 100644 --- a/src/gmpy2_truediv.c +++ b/src/gmpy2_truediv.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_truediv.h b/src/gmpy2_truediv.h index d17d2af2..7386ff3e 100644 --- a/src/gmpy2_truediv.h +++ b/src/gmpy2_truediv.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_types.h b/src/gmpy2_types.h index eff60e1a..32337771 100644 --- a/src/gmpy2_types.h +++ b/src/gmpy2_types.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_vector.c b/src/gmpy2_vector.c index 066550d4..2c0fa54e 100644 --- a/src/gmpy2_vector.c +++ b/src/gmpy2_vector.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_vector.h b/src/gmpy2_vector.h index 5097fcd9..21ad2cb2 100644 --- a/src/gmpy2_vector.h +++ b/src/gmpy2_vector.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_xmpz.c b/src/gmpy2_xmpz.c index 52363e0e..0db07fc0 100644 --- a/src/gmpy2_xmpz.c +++ b/src/gmpy2_xmpz.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * @@ -107,7 +107,7 @@ static PyMethodDef GMPy_XMPZ_methods [] = { "iter_clear", (PyCFunction)GMPy_XMPZ_Method_IterClear, METH_VARARGS | METH_KEYWORDS, GMPy_doc_xmpz_method_iter_clear }, { "iter_set", (PyCFunction)GMPy_XMPZ_Method_IterSet, METH_VARARGS | METH_KEYWORDS, GMPy_doc_xmpz_method_iter_set }, { "make_mpz", GMPy_XMPZ_Method_MakeMPZ, METH_NOARGS, GMPy_doc_xmpz_method_make_mpz }, - { "num_digits", GMPy_MPZ_Method_NumDigits, METH_VARARGS, GMPy_doc_mpz_method_num_digits }, + { "num_digits", (PyCFunction)GMPy_MPZ_Method_NumDigits, METH_FASTCALL, GMPy_doc_mpz_method_num_digits }, { "num_limbs", GMPy_XMPZ_Method_NumLimbs, METH_NOARGS, GMPy_doc_xmpz_method_num_limbs }, { "limbs_read", GMPy_XMPZ_Method_LimbsRead, METH_NOARGS, GMPy_doc_xmpz_method_limbs_read }, { "limbs_write", GMPy_XMPZ_Method_LimbsWrite, METH_O, GMPy_doc_xmpz_method_limbs_write }, diff --git a/src/gmpy2_xmpz.h b/src/gmpy2_xmpz.h index 5945e601..136bf8f1 100644 --- a/src/gmpy2_xmpz.h +++ b/src/gmpy2_xmpz.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_xmpz_inplace.c b/src/gmpy2_xmpz_inplace.c index c864fd83..5ea82aca 100644 --- a/src/gmpy2_xmpz_inplace.c +++ b/src/gmpy2_xmpz_inplace.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_xmpz_inplace.h b/src/gmpy2_xmpz_inplace.h index 99cf921b..f52737b9 100644 --- a/src/gmpy2_xmpz_inplace.h +++ b/src/gmpy2_xmpz_inplace.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_xmpz_misc.c b/src/gmpy2_xmpz_misc.c index aa4a6d6e..f5eb6b32 100644 --- a/src/gmpy2_xmpz_misc.c +++ b/src/gmpy2_xmpz_misc.c @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy2_xmpz_misc.h b/src/gmpy2_xmpz_misc.h index b8f6962a..8d3065af 100644 --- a/src/gmpy2_xmpz_misc.h +++ b/src/gmpy2_xmpz_misc.h @@ -6,7 +6,7 @@ * * * Copyright 2000 - 2009 Alex Martelli * * * - * Copyright 2008 - 2023 Case Van Horsen * + * Copyright 2008 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy_mpz_lucas.c b/src/gmpy_mpz_lucas.c index 5e2748c8..a45ab954 100644 --- a/src/gmpy_mpz_lucas.c +++ b/src/gmpy_mpz_lucas.c @@ -6,7 +6,7 @@ * * * Copyright 2011 David Cleaver * * * - * Copyright 2012 - 2023 Case Van Horsen * + * Copyright 2012 - 2024 Case Van Horsen * * * * The original file is available at: * * * diff --git a/src/gmpy_mpz_lucas.h b/src/gmpy_mpz_lucas.h index 197d1e12..537c1010 100644 --- a/src/gmpy_mpz_lucas.h +++ b/src/gmpy_mpz_lucas.h @@ -4,7 +4,7 @@ * Python interface to the GMP, MPFR, and MPC multiple precision * * libraries. * * * - * Copyright 2012 - 2023 Case Van Horsen * + * Copyright 2012 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/src/gmpy_mpz_prp.c b/src/gmpy_mpz_prp.c index cad50ab9..c28452f6 100644 --- a/src/gmpy_mpz_prp.c +++ b/src/gmpy_mpz_prp.c @@ -6,7 +6,7 @@ * * * Copyright 2011 David Cleaver * * * - * Copyright 2012 - 2023 Case Van Horsen * + * Copyright 2012 - 2024 Case Van Horsen * * * * The original file is available at: * * * diff --git a/src/gmpy_mpz_prp.h b/src/gmpy_mpz_prp.h index 1775fce7..5d91a118 100644 --- a/src/gmpy_mpz_prp.h +++ b/src/gmpy_mpz_prp.h @@ -4,7 +4,7 @@ * Python interface to the GMP, MPFR, and MPC multiple precision * * libraries. * * * - * Copyright 2012 - 2023 Case Van Horsen * + * Copyright 2012 - 2024 Case Van Horsen * * * * This file is part of GMPY2. * * * diff --git a/test/test_mpfr.py b/test/test_mpfr.py index dd771f28..078be0d7 100644 --- a/test/test_mpfr.py +++ b/test/test_mpfr.py @@ -301,6 +301,9 @@ def test_mpfr_mpmath(): assert mpfr(c, precision=10)._mpf_ == (1, mpz(804), -8, 10) assert mpmath.mpf(mpfr(c, precision=10), prec=10) == mpmath.mpf(c, prec=10) assert mpfr(d)._mpf_ == (0, mpz(0), 1, 1) + pytest.raises(TypeError, lambda: gmpy2._mpmath_create(1)) + pytest.raises(ValueError, lambda: gmpy2._mpmath_create(1, 1, -1)) + pytest.raises(TypeError, lambda: mpmath.mpf(("!", 1,))) def test_mpfr_format():