Message336130
In pure Python this seems to be the better option to compute inverses:
def modinv(a, m): # assuming m > 0
b = m
s, s1 = 1, 0
while b:
a, (q, b) = b, divmod(a, b)
s, s1 = s1, s - q * s1
if a != 1:
raise ValueError('inverse does not exist')
return s if s >= 0 else s + m
Binary xgcd algorithms coded in pure Python run much slower. |
|
| Date |
User |
Action |
Args |
| 2019-02-20 17:55:19 | lschoe | set | recipients:
+ lschoe, tim.peters, rhettinger, mark.dickinson, steven.daprano, skrah, pablogsal |
| 2019-02-20 17:55:19 | lschoe | set | messageid: <[email protected]> |
| 2019-02-20 17:55:19 | lschoe | link | issue36027 messages |
| 2019-02-20 17:55:19 | lschoe | create | |
|