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
@kgryte do you have an input which works in the referenced package but not in the suggested code?
afaict both compute-gcd and compute-lcm seem to exist to implement specific algorithms by-the-book. i.e. they are implementing a different algorithm to solve the same problem. if that is the case, it seems this is a valid replacement if you're not concerned with which underlying algorithm has been chosen
if you're not concerned with which underlying algorithm has been chosen
Yes, except consumers should be concerned with the underlying algorithm. Reduction + modulo arithmetic is entirely what those packages are intended to avoid. These packages exist so that consumers don't have to reimplement the underlying algorithms themselves, and you're effectively encouraging imperative inlining versus a declarative import. That, to me, does not seem ideal, especially as lcm/gcd can often be found deep within hot loops. The suggested replacements are difficult for optimizing compilers to optimize.
Activity
kgryte commentedon Nov 10, 2026
The above is not a drop-in replacement for the referenced package.
43081j commentedon Nov 10, 2026
@kgryte do you have an input which works in the referenced package but not in the suggested code?
afaict both compute-gcd and compute-lcm seem to exist to implement specific algorithms by-the-book. i.e. they are implementing a different algorithm to solve the same problem. if that is the case, it seems this is a valid replacement if you're not concerned with which underlying algorithm has been chosen
kgryte commentedon Nov 12, 2026
Yes, except consumers should be concerned with the underlying algorithm. Reduction + modulo arithmetic is entirely what those packages are intended to avoid. These packages exist so that consumers don't have to reimplement the underlying algorithms themselves, and you're effectively encouraging imperative inlining versus a declarative import. That, to me, does not seem ideal, especially as lcm/gcd can often be found deep within hot loops. The suggested replacements are difficult for optimizing compilers to optimize.
43081j commentedon Nov 12, 2026
can you expand on why the pattern should be avoided?
presumably this is the reason:
do you have anywhere we can learn about that? anything that shows us that is the case?