Message409315
About:
TableSize = 101
limits = bytearray(TableSize)
for n in range(0, TableSize):
for k in range(0, n+1):
if comb(n, k) != comb_small(n, k):
(and regardless of whether the last line is replaced with the later correction):
Did you try running that? Assuming "comb_small()" refers to the earlier Python function of that name you posted, it dies in the obvious way:
Traceback (most recent call last):
File "C:\MyPy\temp3.py", line 29414, in <module>
if comb(n, k) != comb_small(n, k) % Modulus:
File "C:\MyPy\temp3.py", line 29404, in comb_small
return (F[n] * Finv[k] * Finv[n-k] % Modulus) << (S[n] - S[k] - S[n-k])
IndexError: list index out of range
This occurs, as expected, when n first reaches 68 (because Cmax = 67 in the code posted for comb_small()).
So it's unclear what you intended to say. Certainly, the current mathmodule.c perm_comb_small() (where "small" appears to mean merely that the args fit in C "unsigned long long") makes no attempt to exploit the newer n <= 67 code Mark checked in. |
|
Date |
User |
Action |
Args |
2021-12-29 18:17:20 | tim.peters | set | recipients:
+ tim.peters, rhettinger, mark.dickinson, serhiy.storchaka, PedanticHacker, mcognetta, Stefan Pochmann |
2021-12-29 18:17:20 | tim.peters | set | messageid: <1640801840.59.0.571380493201.issue37295@roundup.psfhosted.org> |
2021-12-29 18:17:20 | tim.peters | link | issue37295 messages |
2021-12-29 18:17:20 | tim.peters | create | |
|