Precompile a script?



Is there a way to precompile a script, so that I can execute it in batch fast?


To quote the official docs,

To create an incremental precompiled module file, add __precompile__() at the top of your module file (before the module starts). This will cause it to be automatically compiled the first time it is imported. Alternatively, you can manually call Base.compilecache(modulename).


What about a script, not a module?


Put the main computational functions (hopefully you are using functions and not one long Matlab-style script full of globals) of the script into a module.


However, it may not give you the hoped for speed-up, see e.g.