On Thu, 24 Mar 2011 18:32:11 -0700, Carl Banks wrote: > It's probably the least justified builtin other than pow.
I don't know about that. Correctly, efficiently and *quickly* implementing the three-argument version of pow is exactly the sort of thing that should be in the built-ins, or at least the standard library. [steve@sylar ~]$ python3 -m timeit -s "n=2" "(n**30000)%123456789" 1000 loops, best of 3: 633 usec per loop [steve@sylar obfuscate]$ python3 -m timeit -s "n=2" "pow(n, 30000, 123456789)" 100000 loops, best of 3: 6.03 usec per loop That's two orders of magnitude faster. (You need the n=2 to defeat Python's compile-time constant folding, otherwise timing measurements will be misleading.) -- Steven -- http://mail.python.org/mailman/listinfo/python-list