lua-users home
lua-l archive

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

This was one of the best messages (probably, because it was short!) on this thread.

You mean 5x access time for custom function. And that's not including the logic within.

"Nested metatables", I presume, is '__index' with a table reference, am I right?


(of course, creation times are not accounted for in this comparison)

19.1.2005 kello 13:40, Steve Donovan kirjoitti:

 It's interesting to compare various ways of implementing
inheritance in lua.

Here are some numbers:
   - global function call                     1.0
   - copying methods into class        1.5
   - custom __index  function            5.0  (!)
   - nested metatables                      2.0

For the inheritance tests, a method of the base class
was called by an object of a derived class, twice

In summary;  method dispatch isn't too bad, unless
you use a custom function to look up symbols.
Generally keeping 'fat' classes (that include all
methods) is better; this will not depend on
the depth of inheritance.

Of course, your mileage may vary...

steve d.