lua-users home
lua-l archive

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


2012/9/19 Marc Lepage <mlepage@antimeta.com>:
> What I'd like to know is if there are other options or patterns for
> implementing what are essentially objects that have a number of properties
> (fields), without wasting too much memory or performance, where I can do
> things like keep cached derived values and ensure they are kept up to date
> when properties are changed.

Did you benchmark the memory and performance you lose by using a
custom __index, a delegate table, and eventually a custom
implementation of pairs (remember it's simply a global function that
you can replace)? If you did I'd be interested to see these benchmark
results. If not I believe your concerns for optimizations are too
early.

The general consensus is that using proxy tables is slower and uses
more memory than using simple tables, but what matters is how much
slower and how much more memory, and more importantly whether that
becomes too slow or too memory hungry for a given application.