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.19:32:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1639855953.3.0.555730267212.issue37295@roundup.psfhosted.org>
In-reply-to
Content
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() 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]))));
History
Date User Action Args
2021-12-18 20:37:17rhettingerunlinkissue37295 messages
2021-12-18 19:32:33rhettingersetrecipients: + rhettinger, tim.peters, mark.dickinson, serhiy.storchaka, PedanticHacker, mcognetta, Stefan Pochmann, pablogsal
2021-12-18 19:32:33rhettingersetmessageid: <1639855953.3.0.555730267212.issue37295@roundup.psfhosted.org>
2021-12-18 19:32:33rhettingerlinkissue37295 messages
2021-12-18 19:32:33rhettingercreate