alessiogiovanni.bar...@gmail.com writes: > > Could you test pow(a,b,c) where a,b,c are each 300 decimal digits? > > This is an important operation in cryptography, that GMP is carefully > > optimized for. Thanks. > > Ok, thanks for your answers. I understand the problems of licensing, > but we could to learn from GMP's source code to improve the Python's > int implementation, mainly because, GMP is very fast.
GMP is a lot more complicated than Python bigint arithmetic. It's optimized separately for many different cases and operations. It uses assembly language for innder loops. And the modular exponential operation pow(a,b,c) is especially carefully tuned in complicated ways. Python tries to just have straightforward, reasonably portable bigints. I did something like try: import gmpy pow=gmpy.modexp # or whatever it was called except ImportError: pass in an application a while back, so that it would use gmpy if possible and Python longs otherwise. That worked pretty well. -- http://mail.python.org/mailman/listinfo/python-list