This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author h.venev
Recipients christian.heimes, gvanrossum, h.venev, mark.dickinson, tim.peters, vstinner
Date 2014-04-07.10:45:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
What about using PyVarObject of mp_limb_t and mpn instead of mpz_t? 

   - Check signs and allocate.
   - Possibly compare absolute values.
   - Call mpn_(add|sub)_n and possibly mpn_(add|sub)_1 if the integers have different sizes.
   - Overhead for small integers: 1 Python->GMP, 1 if.

   - Same as addition

   - Check signs and allocate.
   - Call mpn_mul.
   - Overhead for small integers: 1 Python->GMP, 2 GMP->GMP, 3 if.

   - Check signs and allocate.
   - Call mpn_div_q.
   - Overhead for small integers: 1 Python->GMP, 1 GMP->GMP, 1 if, maybe a 3 more ifs in mpn_divrem_1.

   - Create mpz_t values using MPZ_ROINIT_N(limbs, size) and call mpz_pow(m?). Copy from mpz_limbs_read(result).

* The overhead is after checking if both arguments are integers until going to the right function (mpn_mul -> mpn_mul_n -> mpn_mul_basecase).

Checks for adding integers < 1<<(GMP_NUMB_BITS-1), multiplying < 1<<(GMP_NUMB_BITS/2) and dividing < 1<<GMP_NUMB_BITS can be added.
Date User Action Args
2014-04-07 10:45:27h.venevsetrecipients: + h.venev, gvanrossum, tim.peters, mark.dickinson, vstinner, christian.heimes
2014-04-07 10:45:27h.venevsetmessageid: <>
2014-04-07 10:45:27h.venevlinkissue1814 messages
2014-04-07 10:45:26h.venevcreate