This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients PedanticHacker, Stefan Pochmann, mark.dickinson, mcognetta, pablogsal, rhettinger, serhiy.storchaka, tim.peters
Date 2021-12-18.20:40:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
For the small cases (say n < 50), we can get faster code by using a small (3Kb) table of factorial logarithms:

   double lf[50] = [log2(factorial(n)) for n in range(50)];

Then comb() and perm() function can be computed quickly and in constant time using the C99 math functions:

   result = PyLong_FromDouble(round(exp2(lf[n] - (lf[r] + lf[n-r]))));
Date User Action Args
2021-12-18 20:40:55rhettingersetrecipients: + rhettinger, tim.peters, mark.dickinson, serhiy.storchaka, PedanticHacker, mcognetta, Stefan Pochmann, pablogsal
2021-12-18 20:40:55rhettingersetmessageid: <>
2021-12-18 20:40:55rhettingerlinkissue37295 messages
2021-12-18 20:40:55rhettingercreate