Closed GoogleCodeExporter closed 8 years ago
erroit in reproduction of yhe issue: use
gmpy2.mul_2exp(a, 4)
Original comment by albert.k...@gmail.com
on 25 Oct 2013 at 4:30
Actually, I need not at all shifts. As I think, GMP does some like pointer
rearrangement if the sgift value alighs byte border. So that instead of >> 1024
times we can just copy byte sequense started from (byrt pointer + 1024/8)
Sincerely, Albert
Original comment by albert.k...@gmail.com
on 25 Oct 2013 at 4:35
The << and >> operators call mpz_mul_2exp and mpz_fdiv_q_2exp so they work
efficiently. The overhead is less for using <</>> versus calling a function.
The difference is probably not relevant for such large numbers. You can also
use f_div_2exp for division by a power of 2. The leading f_ implies floor
division. There are also ceiling division (c_) and truncating division (t_).
If your calculations primarily use in-place operators (+=, <<=, etc.), the xmpz
type may e slightly faster. The xmpz type is mutable (the value can change
without creating a new object). In some circumstances they are faster but they
can't be used as a key in a dictionary. If you use an xmpz type with normal
operations (=, <<, etc.), the result will be an mpz. xmpz type also supports
inplace bit manipulation using the standard slice notation.
Original comment by casevh
on 26 Oct 2013 at 12:31
Closing.
Original comment by casevh
on 4 Nov 2013 at 4:52
Original issue reported on code.google.com by
albert.k...@gmail.com
on 25 Oct 2013 at 4:28