lua-users home
lua-l archive

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

Move along, move along, I’ve nothing constructive to say here J


I know I’m flogging a dead horse here, and I do not expect it ever to change (or want it to, as it would be too disruptive), but things like this make me more certain in my view that combining dictionaries/hash tables and contiguously-indexed-arrays in Lua was a mistake.


In my mind, they’re just different things.




From: [] On Behalf Of Pascal Leclerc
Sent: 06 June 2007 15:58
To: Lua list
Subject: Re: Sieve of Eratosthenes performance question


If that's the case, the deprecated table.setn wouldn't help to do this in just one call ? Was it wise to deprecate it ?

2007/6/6, Roberto Ierusalimschy <>:

> I believe the difference is because I made 'composite' an array with
> contiguous numerical indexes, with optimized access in Lua 5.1 (direct
> offset computing), while in the previous code, Lua probably has to make
> more complex tests (hashing the index?) to see if the slot is empty.

This is my guess, too. You can check by initializing the "prime" array
with falses before starting the sieve (as you do with 'composite').

-- Roberto