Author mark.dickinson
Recipients PedanticHacker, Stefan Pochmann, mark.dickinson, mcognetta, pablogsal, rhettinger, serhiy.storchaka, tim.peters
Date 2021-12-21.09:15:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1640078125.64.0.95495357946.issue37295@roundup.psfhosted.org>
In-reply-to
Content
That computation of the shift can be simplified to require only one popcount operation. With F and Finv as before:


def comb_small(n, k):
    assert 0 <= k <= n <= Nmax
    return (F[n] * Finv[k] * Finv[n-k] % 2**64) << (k ^ n ^ (n-k)).bit_count()
History
Date User Action Args
2021-12-21 09:15:25mark.dickinsonsetrecipients: + mark.dickinson, tim.peters, rhettinger, serhiy.storchaka, PedanticHacker, mcognetta, Stefan Pochmann, pablogsal
2021-12-21 09:15:25mark.dickinsonsetmessageid: <1640078125.64.0.95495357946.issue37295@roundup.psfhosted.org>
2021-12-21 09:15:25mark.dickinsonlinkissue37295 messages
2021-12-21 09:15:25mark.dickinsoncreate