Hy

Hy (http://docs.hylang.org/) is the dialect of Lisp, and is written entirely in Python. Many similar projects that implement other code in Python usually try only to tokenize the plain form of code that's provided either as a file-like object or string and interpret it as a series of explicit Python calls. Unlike others, Hy can be considered as a language that runs fully in the Python runtime environment, just like Python does. Code written in Hy can use the existing built-in modules and external packages and vice-versa. Code written with Hy can be imported back into Python.

To embed Lisp in Python, Hy translates Lisp code directly into Python AST. Import interoperability is achieved using the import hook that is registered once the Hy module is imported into Python. Every module with the .hy extension is treated as the Hy module and can be imported like the ordinary Python module. The following is a hello world program written in this Lisp dialect:

;; hyllo.hy 
(defn hello [] (print "hello world!")) 

It can be imported and executed with the following Python code:

>>> import hy
>>> import hyllo
>>> hyllo.hello()
    hello world!

If we dig deeper and try to disassemble hyllo.hello using the built-in dis module, we will notice that the byte code of the Hy function does not differ significantly from its pure Python counterpart, as shown in the following code:

>>> import dis
>>> dis.dis(hyllo.hello)
  2           0 LOAD_GLOBAL        0 (print)
              3 LOAD_CONST         1 ('hello world!')
              6 CALL_FUNCTION      1 (1 positional, 0 keyword pair)
              9 RETURN_VALUE
>>> def hello(): print("hello world!")
... >>> dis.dis(hello) 1 0 LOAD_GLOBAL 0 (print) 3 LOAD_CONST 1 ('hello world!') 6 CALL_FUNCTION 1 (1 positional, 0 keyword pair) 9 POP_TOP 10 LOAD_CONST 0 (None) 13 RETURN_VALUE