lua-users home
lua-l archive

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


Title: Message
Hi all. Has anyone done any performance evaluation of key lookups? Specifically, I'm using Lua in an environment where performance of script execution will be important, and I'm thinking of avoiding string keys completely for performance reasons, and instead planning on having numeric globals, so that instead of
 
mytable = {prop1 = X, prop2 = Y}
 
I'd have
 
prop1 = 1
prop2 = 2
mytable = {[prop1] = X, [prop2] = Y}
 
At first I thought it would be a slam dunk in terms of performance, but then I realized that the second approach requires a global lookup instead of a key lookup, which is essentially the same thing (?) plus the numeric key index. So maybe the second approach is actually worse?
 
Any insights into the absolute most efficient way to index tables would be appreciated. Using no keys, however, is probably not an option.
 
Thanks,
 
Curt