lua-users home
lua-l archive

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


On Wed, 27 Feb 2002, Curt Carpenter wrote:

> > Yes, but the performance issue cuts both ways. The most simple 
> > way to keep the count in Lua internally would be to 
> > add an internal "element_count" variable to each table. 
> > However, in that case, for each addition or deletion of an element 
> > to th table, you need to update this internal variable. This does not 
> > sound like much, but what if you have a data table of 
> > thousands of elements?  
> 
> It doesn't matter how many elements are in the table. In fact when the
> table is huge is exactly when it's MORE important for Lua to own the
> size for you so people don't unwittingly iterate over huge tables just
> to get their size. Incrementing/decrementing an int is like a couple
> machine instructions and is absolutely not even on the performance radar
> in terms of all the other stuff going on to add/remove an element from a
> table. I would wager you couldn't even measure the perf difference.

Sounds like what we need is someone to hack to source and try it, then do
some performance measurements. I'll do it, but not until the end of March,
my time is too full between now and then.

  - Tom Wrensch