lua-users home
lua-l archive

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

Canute Bigler wrote:
> Thank you all for the responses so far.  I had considered the route of
> compiling the script to bytecode and then embedding it as a buffer that
> I could then load.  I'd not yet compared the timing difference between
> the two methods.

Loading bytecode is substantially faster than compiling source.

If you want an example, my wordgrinder app does this:

The relevant code to load the bytecode blocks is in src/c/lua.c,
script_load_from_table(), but it's pretty much trivial; of more interest
 is probably tools/multibin2c.lua, which is the script that takes all
the bytecode files and turns them into the C source file that gets
compiled in to the rest of the program.

┌─── ───── ─────
│ ⍎'⎕',∊N⍴⊂S←'←⎕←(3=T)⋎M⋏2=T←⊃+/(V⌽"⊂M),(V⊝"M),(V,⌽V)⌽"(V,V←1⎺1)⊝"⊂M)'
│ --- Conway's Game Of Life, in one line of APL

Attachment: signature.asc
Description: OpenPGP digital signature