[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: table library changes (was Re: table.new in 5.3?)
- From: Coda Highland <chighland@...>
- Date: Tue, 26 Nov 2013 09:37:10 -0800
On Tue, Nov 26, 2013 at 2:42 AM, John Hind <firstname.lastname@example.org> wrote:
>> Date: Mon, 25 Nov 2013 22:52:35 -0500
>> From: Sean Conner <email@example.com>
>> Subject: Re: table library changes (was Re: table.new in 5.3?)
>> > > I actually went to the trouble to measure the code and indeed, the
>> > > "optimized" version does indeed run faster (about 10x), *BUT* it
>> > > does *NOT* produce identical results.
>> > >> > > I realize you were trying to prove a point here, but it might be
>> > > made a bit better if both code fragments actually did identical work.
>> > What's the difference?
>> The size of the resulting arrays (original: 9909 "optimized": 9899) and
>> 90 incorrect values:
>> index orig optmized
>> 10 11 10
>> 11 13 102
> Good point, well made! Like Galileo, seeing that the answer was obvious from the thought experiment, I did not bother doing the actual experiment. But debug the code and the answer will be the same. Note that the 10x improvement comes from the number of elements removed - remove 1001 elements and it will be (close to) 1000x better!
> My screw-up does show that ad-hoc coding this kind of thing is error prone. So it would be worth having multi-element insert and remove in a library, but a Lua library please, not 'C'. As they say (but do not do) at Yahoo, we should "eat our own dog food"!
Lua's claim to fame is embedding itself into another application with
functionality implemented in C exposed by the host. Implementing it in
C is no less dogfooding than implementing it in Lua.