Am I right in thinking that it would be better if you reduce access to the file system at each iteration?
In general, you should rather be guided than to assume, but it is pretty cut and dried: "disk IO, compile, execute" vs "execute". Of course, the latter will be faster.
Is there a way to cache the script inside the Lua virtual machine?
If you dofile or dostring any global variables that the script you created will be displayed, will be read / callable. If you want your scripts to not change the global virtual machine namespace, you can open the API routine (in the host) that your script can call to register the callback.
source share