I am getting into the habit of writing functions that take varargs, eg
foo(xs...) = reduce(some_op, map(some_function, xs))
and then either calling them as
foo(1,2) for a small number of arguments, or
foo(some_vector...) for iterables. I am wondering about the efficiency like this: in the second case, is there some intermediate form of the arguments that is constructed, or does
some_vector go directly to the body? What about some intermediate case, eg
foo(x, ys...)? Are there rules of thumb for when intermediate allocation happens?
I am not only asking about current optimizations, but about what should be considered idiomatic in the long run, even if it is not optimized fully in
0.5.0. Historically, some languages impose limits on varargs (eg not more than a few thousand etc), but I could not find this in the Julia manual, and did not run into limits in practice, so I thought I would ask.