Berry Schoenmakers <l.a.m.schoenmak...@tue.nl> added the comment:

I had the same reservations but after rethinking it several times concluded 
that the modulus argument would fit really well.

Indeed, Mathematica doesn't support the Modulus option for the Product[] 
function. But they don't even support it for the Power[] function, one needs to 
use PowerMod[] for that. 

Python has the extra option for its built-in pow(), and sensibly restricts this 
to the case of integer arguments only. 

To do modular arithmetic, even with big numbers, in Python is really nice and 
easy using the % operator. And it's all pretty efficient as well. The only 
exception where efficiency becomes an issue is the pow() function.

To maintain that balance with the new prod() function around, the modulus 
argument would do the job. We can continue to do all modular arithmetic in a 
natural way, yielding programs that are perfectly readable and with very decent 
performance, now with prod() in the language as well.

Taking larger modular products is a common thing to do in modern crypto, and 
Python is a popular platform for this. Next to the example of prod_i g[i]**s[i] 
mod z, which is like a Pedersen multi-commitment, it also arises when computing 
Lagrange coefficients (used in Shamir secret sharing) and related determinants 
for Vandermonde matrices.

One would also be able to things like prod(range(1, n), n) == n - 1 for 
Wilson's primality test. (Extending the factorial() function with a modulus 
argument would be taking things too far, probably, but the modular version 
would now be available anyway via prod().)

So, my feeling is that there are sufficiently many use cases around. And, I'm 
kind of assuming that it's not too much effort to add a modulus argument to 
prod(), but maybe that's not really the case.

----------

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

Reply via email to