Python元循环评估器
在编程入门课程中编写 Lisp 元循环求值器的情况并不少见。有没有尝试为 Python 做这件事?
是的,我知道 Lisp 的结构和语法非常适合元循环求值器等。Python 很可能会更困难。我只是好奇是否有过这样的尝试。
It's not uncommon for an intro programming class to write a Lisp metacircular evaluator. Has there been any attempt at doing this for Python?
Yes, I know that Lisp's structure and syntax lends itself nicely to a metacircular evaluator, etc etc. Python will most likely be more difficult. I am just curious as to whether such an attempt has been made.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于那些不知道什么是元循环评估器的人来说,它是一个用要解释的语言编写的解释器。例如:用 Lisp 编写的 Lisp 解释器,或者在我们的例子中,用 Python 编写的 Python 解释器。如需了解更多信息,阅读 SICP 的本章。
正如 JBernardo 所说,PyPy 就是其中之一。然而,PyPy 的 Python 解释器(即元循环求值器)是在名为 RPython.
您会很高兴地知道,从 1.5 版本开始,PyPy 完全符合官方 Python 2.7 规范。更重要的是:PyPy 在性能基准测试中几乎总是击败 Python。
有关详细信息,请参阅 PyPy 文档 和 PyPy 额外文档。
For those who don't know what a meta-circular evaluator is, it is an interpreter which is written in the language to be interpreted. For example: a Lisp interpreter written in Lisp, or in our case, a Python interpreter written in Python. For more information, read this chapter from SICP.
As JBernardo said, PyPy is one. However, PyPy's Python interpreter, the meta-circular evaluator that is, is implemented in a statically typed subset of Python called RPython.
You'll be pleased to know that, as of the 1.5 release, PyPy is fully compliant with the official Python 2.7 specification. Even more so: PyPy nearly always beats Python in performance benchmarks.
For more information see PyPy docs and PyPy extra docs.
我想我在这里写了一个:
I think i wrote one here: