I ran some tests to compare the performance difference between between GMPY 1.04, 1.11, and 1.11 with mutating behavior. I tested multiplication of a 128-bit number by 1 with the commands:
py26 -m timeit -s "import gmpy;a=gmpy.mpz(11)**37" "a=a*1" and py26 -m timeit -s "import gmpy;a=gmpy.mpz(11)**37" "a*=1" gmpy 1.04 a=a*1: 0.132 usec a*=1: 0.135 usec gmpy 1.11 a=a*1: 0.0894 usec a*=1: 0.0745 usec gmpy 1.11 with mutating behavior a=a*1: 0.0895 usec a*=1: 0.0683 usec Between 1.04 and 1.11, I added caching of GMPY mpz objects, reworked the coercion process, and optimized the path of inplace operations. Inplace operations still returned new objects but the overhead is much less. 1.11 with mutating behavior does real inplace operations but the improvement isn't nearly as significant as all the other changes. There may be GMP/MPIR functions that are faster when the source and destination are the same and that may change the results. I also tested (with gmpy 1.11 and mutating): py26 -m timeit -s "import gmpy;a=gmpy.mpz(11)**37" "a.__imul__(1)" The results where 0.184 usec. Attribute lookups are slower than overload builtin operators. I'm currently working on gmpy2 which will add an xmpz type which will only be mutable so I may be able to improve the performance. casevh -- You received this message because you are subscribed to the Google Groups "mpir-devel" group. To post to this group, send email to mpir-de...@googlegroups.com. To unsubscribe from this group, send email to mpir-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/mpir-devel?hl=en.