Common Lisp: Does `load` compile a file?

Suppose I have a file called "includes.cl" inside which there are several function definitions. Now I have two ways to use these functions:

  • (load "includes.cl")
  • (load (compile-file "includes.cl"))

Is the latter faster than the former? I mean only the speed of the function.

+4
source share
1 answer

To answer your question, there is no way to say a priori which of your two forms is faster. However, your second form is likely to cause functions and macros found in "include.cl" to execute faster.

Moreover, no matter how you recompile the C library every time you link something to it, you should not recompile a Lisp before each load .

At least you should use something like load-compile-maybe or an analogue of Lisp make , like asdf .

EDIT: you are using SBCL, which does not have an interpreter, only a compiler. This means that all the code was compiled before it was executed, so the two forms in your question are equivalent. However, the bulk of the cost is in the compile-file , not in the load , so it is a very good idea to compile the file once and then load it with (load "includes") (note the lack of file type, AKA, extension).

+4
source

Source: https://habr.com/ru/post/1501127/


All Articles