Why can Lisp with all its dynamic features be statically compiled but Python cannot (without losing all its dynamic features)?
Processing is slower in the Lisp Programming language when compared to the Python programming language. Processing is faster in Python programming language when compared to Lisp Programming language. Lisp Programming language is not preferred much to work on Artificial Intelligence.
Common Lisp is AOT compiled to the metal so it starts up fast and runs fast. CL is often within a factor of 2 of C speed and dramatically faster than plain Python.
There is nothing that prevents static compilation of Python. It's a bit less efficient because Python reveals more mutable local scope, also, to retain some of the dynamic properties (e.g. eval) you need to include the compiler with the compiled program but nothing prevents that too.
That said, research shows that most Python programs, while dynamic under static analysis, are rather static and monomorphic at runtime. This means that runtime JIT compilation approaches work much better on Python programs. See unladen-swallow, PyPy, Psyco for approaches that do compile Python into machine code. But also IronPython and Jython that use a virtual machines originally intended for a static languages to compile Python into machinecode.
For what its worth, Python scripts are compiled into .pyc files when the are executed, see "Compiled" Python files.
You can also use a tool such as py2exe to compile a Python program into an executable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With