lua-users home
lua-l archive

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

On Wed, Oct 5, 2011 at 4:05 PM, joao lobato <> wrote:
>> What is the problem with a bunch of tables?
>>> Wouldn't a simple, fixed size, integer indexable (1 based, of course
>>> ;-) ), array type be better suited for the role of building block?
>> If you want Fortran, you know where to find it... :-)
>> Plus Lua does very well on these arrays already...
> Well, I believe you. Not having performed any benchmarking I wouldn't
> argue about the overhead of the rest of the table implementation; it
> was just a gut feeling :-)

a case in point:

once upon a time,
(, there was a
thread where a few of us enjoyed optimizing a priority queue;
comparing a heap structure with a sorted table.

at first, a binary heap (easy to implement on an array) performed
really well; but then Gé Weijers surprised everybody with the speed of
a skew heap (that uses a tree-like structure internally).

the surprising part is that Gé's code instantiated lots of small
tables (with named fields!) to create the internal tree, but it still
was far faster than the supposedly-optimized binary heap (which used a
single integer-indexed array).

moral of the story: Lua tables are wicked fast!