Saturday, 15 January 2011

c++ - Bignum implementation that has efficient addition of small integers -


I am using Python's native bignam for an algorithm and converting it to C ++ Have decided to do When I used to work for a long time, C ++ was about 100x faster than Pygm, but when I used GMP binding in C ++, it was only 10x faster than the dragon (for the same cases Which are fit for a long time)

Is there a better Bingim implementation for large number of small additions? For example, we have a large number, we add very few + 1, +21, +1 and every time and once more adds a bigger number M?

one in the GMP library

  zero mpz_add_ui (mpz_t rop, mpz_t Op1, unsigned long end op2)  

I do not know if gmpy uses that, but if it tries to add a normal python by creating an mpz vs mpz and mpz Attempts to add to mpz and see whether it is fast or not.

>

Edit

I tried some benchmarking and found that it does not make any difference

  $ Python -m timeit - c 'gmi import mgg & gt; A = MP3 (10 ** 1000) "A + 1" 100000 loop, Best 3: 5.4 per pipe per python -M timit- MPEG import from MPZ A = MP3 (10 ** 1000);  

So I do not use the GMI mpz_add_ui as I really expect That's too fast.


No comments:

Post a Comment