lua-users home
lua-l archive

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

> Hello Roberto,
> Wednesday, December 13, 2006, 7:17:17 PM, you wrote:
> RI> By "expensive" you mean too slow? If you are going to call back Lua,
> RI> it seems that two extra table accesses should make no relevant difference.
> I think sometimes it seems slow, if I only call back lua for a simple operation. (IMHO)
> [...]
> test() cost more time than dummy()

My point is that usually you do not call back Lua to do nothing. I guess
that, if your function is going to do anything useful, chances are that
the cost of two table accesses will be diluted. The question is not
whether there will be a cost (any operation has a non-zero cost),
but whether the cost is relevant enough to justify some action.

In the case you really need to optimize, there may be other ways to
optimize instead of adding new functions to the API. (For instance, in
your case maybe you could set the weak table as the environment of your
function. That would eliminate one of the accesses. But this is still
"thinking local"...)

-- Roberto