➜

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.

作者 h.venev
收信人 christian.heimes, gvanrossum, h.venev, mark.dickinson, tim.peters, vstinner
日期 2014-04-07.10:45:26
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <1396867527.68.0.161435634848.issue1814@psf.upfronthosting.co.za>
In-reply-to
内容
What about using PyVarObject of mp_limb_t and mpn instead of mpz_t? 

Addition:
   - 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.

Subtraction:
   - Same as addition

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

Division:
   - 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.

Pow:
   - 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.
历史
日期 用户 动作 参数
2014-04-07 10:45:27h.venev修改recipients: + h.venev, gvanrossum, tim.peters, mark.dickinson, vstinner, christian.heimes
2014-04-07 10:45:27h.venev修改messageid: <1396867527.68.0.161435634848.issue1814@psf.upfronthosting.co.za>
2014-04-07 10:45:27h.venev链接issue1814 messages
2014-04-07 10:45:26h.venev创建