擅长:python、mysql、java
<p>Node使用一个<a href="http://en.wikipedia.org/wiki/Just-in-time_compilation">JIT compiler</a>,它被设计用来注意同一代码块在同一类型的输入下运行多次,并将其编译为机器代码。Node甚至可能注意到这是一个纯函数并内联了一些结果,但是根据这种编译器的本质,很难从外部分辨出来。</p>
<p>CPython是一个天真的翻译,会按照你说的做。不过,目前正在尝试编写一个名为<a href="http://www.pypy.org/">PyPy</a>的Python JIT(用Python编写,同样如此),正如您所看到的,thusfar的结果很有希望:</p>
<pre><code>$ time python2 fib.py
9227465
python2 fib.py 2.90s user 0.01s system 99% cpu 2.907 total
$ time pypy fib.py
9227465
pypy fib.py 1.73s user 0.03s system 96% cpu 1.816 total
</code></pre>