lua-users home
lua-l archive

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

On Wed, Jan 12, 2011 at 12:57 PM, Murray S. Kucherawy <> wrote:
> I’m not sure I understand the 5.1 documentation so can someone verify the
> following for me?
> I’d like to read a Lua script, compile it with lua_load(), and then have it
> around to re-use in any number of future states.  So I create a first
> lua_State handle, compile the script with lua_load(), then use lua_dump() to
> get the compiled version back out and discard this lua_State.
> Then for each future lua_State I create, use lua_load() but this time pass
> the output of lua_dump() as its input, and then use lua_pcall() to execute
> it.
> Does that sound right?

Its hard to know what you are trying to do.

Why would you compile with one state, and use dump, is it supposed to
be an optimization?

Creating a new state for each execution is likely to be much slower
than compiling....

You're probably better loading once, storing the function, and then
calling it, in the same state, repeatedly.

And the best optimization you can make is probably using luajit, which
doesn't support lua_dump(), as far as I know.