pock: Use `MPMul' so that we can avoid `reduce'.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 22 Oct 2019 11:14:10 +0000 (12:14 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 11 Apr 2020 11:44:21 +0000 (12:44 +0100)
For some reason, Python 3 hides `reduce' away in some library module.
Anyway, we have a very efficient mass-multiplier so we might as well use
it.

pock

diff --git a/pock b/pock
index a980cbe..377b811 100644 (file)
--- a/pock
+++ b/pock
@@ -49,12 +49,8 @@ class ExpectedError (Exception):
   pass
 
 def prod(ff, one = 1):
-  """
-  Return ONE times the product of the elements of FF.
-
-  This is not done very efficiently.
-  """
-  return reduce(lambda prod, f: prod*f, ff, one)
+  """Return ONE times the product of the elements of FF."""
+  return C.MPMul().factor(one).factor(ff).done()
 
 def parse_label(line):
   """