lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, Oct 29, 2020 at 1:21 AM Andrew Gierth
<andrew@tao11.riddles.org.uk> wrote:

> then averaged over a large number of calls, with 5 to 50 results in
> the list, foo2 is around 3x slower than foo1. The proportional speed
> difference does not seem to be narrowing for longer argument lists.

I am not sure whether this is trying to dispute what I said. I was
talking about the performance in the general case. I did say that in
the specific case that you are addressing tables were redundant.

This can be seen without benchmarking. The problem with variadic
arguments is that every function call with them is O(n), where n is
the number of arguments. Just the call, ignoring whatever the function
does. The same is true of return ... .

Each invocation of either foo1 or foo2 has a variadic argument call
and (essentially) a variadic argument return. On the other hand, this
is the entire functionality of foo1, while foo2 does more. So foo2
should be expected to be slower than foo1 no matter what n.

Cheers,
V.