Marking more standard library methods as pure to enable LLVM optimizations?

To elaborate, what I’ve done in Grassmann.jl is to define some of my own dispatch such as

module Grassmann
@pure binomial(n::Int,k::Int) = Base.binomial(n,k)
end

This replaces the Base.binomial method with a local method that is pure.

It is not recommended to make the base arithmetic pure, but you can easily make pure versions of base methods locally by simply redirecting dispatch. This does not affect the global behavior, only local.

1 Like