gladman added the comment:

You might be right that it is not worth adding the ability to handle a variable 
number of parameters in the new gcd.  But this depends on whether you are right 
that this would add a significant burden to the implementation.  I am not sure 
that it would.
But for pure Python implementations of gcd and gcdm:

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

def gcdm(a, *r):
  for b in r:
    while b:
      a, b = b, a % b
  return a

using the second of these alone when compared with the first plus reduce on a 
10000 length sequence of random numbers in 0 <= r < 10 ** 12 gives speed 
improvement of over 25%.  

And, since we are looking for speed improvements, a further possible 25% is a 
worthwhile gain for a common pattern of gcd use.  Which is why I believe it is 
worth asking the question.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22477>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to