Is @evalpoly needed anymore?

Julia provides two ways of polynomial evaluation: one as a function (evalpoly) and the other as a macro (@evalpoly). My understanding is that the macro can (sometimes) be faster than the function due to inlining. However, Julia 1.8 now supports @inline at the call-site now. So would @inline evalpoly(...) have the same performance characteristics as @evalpoly(...).

The macro is mainly there for backwards compatibility as far as I know. The function form is supposed to be just as fast as long as you pass a tuple of coefficients. But there were some cases where it caused a slowdown due to a failure to inline; that might be improved by @inline?

See the discussion in Add evalpoly function by MasonProtter · Pull Request #32753 · JuliaLang/julia · GitHub and the inlining issue discussed here.

(Probably the documentation for @evalpoly should be updated.)

2 Likes