Message362534
Ya, I'll close this, channeling that Raymond would also reject it for now (although he's certainly free to reopen it).
There's nothing wrong with adding such functions, but the `math` module is already straying too far from its original intent as a home for floating-point functions, nearly all of which had counterparts in `cmath`. _If_ we had a, say, `imath` module, it would be a much easier sell.
These are just "too specialized". I'd put them in the same class as, say, a new function to compute the Jacobi symbol. Very handy but only for a vanishingly small percentage of Python users.
Probably _the_ most common use for xgcd (or egcd, either of which I suggest are better names than `bezout` - "extended gcd" is descriptive and commonly used) is for finding modular inverses, but `pow()` does that now directly.
For Chinese remainder, I'd suggest two changes:
1. Generalize to any number of bases. The 2-base case is common in toy RSA implementations, but in that context a more efficient way is generally used, based on precomputing "helper constants" specific to the modulus's 2 factors.
2. Since the same bases are generally used over & over while only the remainders change, the function signature would be more usable if it accepted a sequence of remainders, and a sequence of corresponding bases, as two distinct arguments. |
|
Date |
User |
Action |
Args |
2020-02-23 19:44:10 | tim.peters | set | recipients:
+ tim.peters, rhettinger, mark.dickinson, Dennis Sweeney |
2020-02-23 19:44:10 | tim.peters | set | messageid: <1582487050.28.0.353825547775.issue39657@roundup.psfhosted.org> |
2020-02-23 19:44:10 | tim.peters | link | issue39657 messages |
2020-02-23 19:44:10 | tim.peters | create | |
|