[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5.4-work1 with first class arrays (implementation & benchmarks)
- From: pocomane <pocomane_7a@...>
- Date: Wed, 28 Mar 2018 09:35:08 +0200
On Wed, Mar 28, 2018 at 7:00 AM, Petri Häkkinen <petrih3@gmail.com> wrote:
> The original email outlined how this would work. The patch implements # in constant time for arrays (note that this does not negatively affect the performance of tables — see benchmarks). Once you have arrays you no longer need # operator for tables. So # for tables could be first deprecated and ultimately removed. At this point you have # which works for arrays, is extremely fast, and does not have issues with holes. Problem solved!
If # for table is removed, I probably will re-implement it by myself.
The point is: I often found the current # behaviour very useful, not
something to fight against. E.g. I can write `t[1+#t]=x` and be sure
that the `x` is added in a free space!
Moreover, about your benchmark, I think that comparing # with the
access to a stucture field is a bit unfair. In lua you will never use
# on tables with holes (when performance is important). I would
compare it against a the common .n idiom, or a full
Pure-Lua-Array-Type solution.
And, finally, a question for all the list: how much in your opinion is
the performance important? A proper implemented pure-lua-array can do
everything in O(1), so the gain of a native solution will be always a
constant factor. If this factor is, let's say 10%, it worth? And 20%?
100%?