Skip to content

better inlining of splatting with tuples of known length #20196

@stevengj

Description

@stevengj

Since ntuple has a variant that works with Val{N} (which I learned recently from @JeffBezanson), I was hoping that the compiler could do a good job with:

foo{N}(f, args::Vararg{Any,N}) = f(ntuple(i -> args[i]+1, Val{N})...)

but foo(+, 1,2) seems to be quite slow — 200x slower (according to @btime) than bar(+, 1,2) for bar(f,x,y) = f(x+1,y+1), and @code_llvm foo(+, 1,2) is nasty looking.

I realize that I could use generated functions for this, but I was hoping to avoid that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions