You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is already using that algorithm, but since it's written for generic T: Integer, it's keeping those iterative values as BigUint in your case, rather than local n: usize, k: usize. I'll bet if you profile this, it will be dominated by heap activity. If so, rust-num/num-bigint#307 would probably help a lot by keeping those small values inline. There's also a GCD to try to avoid overflow, which is irrelevant when using BigUint.
So I think num_integer::binomial still won't be as fast as a bespoke non-generic implementation. Maybe we should move the implementation into Integer methods, so num-bigint can better optimize this itself.
Activity
cuviper commentedon Jan 29, 2025
It is already using that algorithm, but since it's written for generic
T: Integer, it's keeping those iterative values asBigUintin your case, rather than localn: usize, k: usize. I'll bet if you profile this, it will be dominated by heap activity. If so, rust-num/num-bigint#307 would probably help a lot by keeping those small values inline. There's also a GCD to try to avoid overflow, which is irrelevant when usingBigUint.So I think
num_integer::binomialstill won't be as fast as a bespoke non-generic implementation. Maybe we should move the implementation intoIntegermethods, sonum-bigintcan better optimize this itself.thomasarmel commentedon Jan 29, 2025
Oh ok thanks for the quick response