I can't speak for everyone else, but I personally am extremely interested in using RPython as a general-purpose language. To answer some other people's questions:
Why? Because Cython is a pain to figure out how to use. If you don't put in a lot of tricky type declarations just right, you don't get any speedup. With RPython, it will run fast or it won't run at all.
Using PyPy offers a good speedup, but currently not nearly as much as RPython.
RPython might be a good way to get super-fast, somewhat Pythonic code. Here's an example to help you get started. I'm not aware of any large projects to do this, unfortunately.
Yes, there is already a project to use the translation tool chain of PyPy to create standalone executables and libraries using RPython. It is called RPythonic.
A general purpose RPython would not be a competitor for CPython and PyPy. It wouldn't even be a competitor for things like Cython.
Why? Because RPython is not Python!! RPython is merely a language which shares some syntax with Python; enough that a Python interpreter can execute RPython code, but you cannot take Python code and compile it as RPython.
The restrictions on Python that are added to enable RPython to be statically typed and compiled (indeed, to have static type inference) are so severe that they completely change the language. If you want to write an RPython program, you have to decide to do so up front and write it in RPython. You can't write a program in Python and then decide to compile it as RPython, and you can't even tweak a realistic Python program a bit to make it RPython. Normal Python code is nothing like normal RPython code; writing RPython is more similar to writing Java or C#.
So if you want to write general programs in Python but you want them to go faster, RPython has very little to offer you. That's the niche PyPy's Python interpreter is trying to fill.
If you want to write general programs in a lower level compiled language because you need your program to run faster than Python, then there are existing very mature languages and libraries for that, like Java or C#.
The reason to code in RPython would be to do something that is particularly made better by RPython. Like writing interpreters to which you can add garbage collectors and JIT compilers without having to write them by hand! Here RPython shines, and yes I would be very interested in a more polished and usable RPython interpreter-writing environment. But as a general purpose programming language for writing programs that don't particularly benefit from RPython's specialities, it would simply be a monstrous amount of work to get it to the point where it could compete with existing languages that already fill that role better. It barely even has a standard library now (because almost none of Python's extensive standard library is usable in RPython), for example.
From the looks of it, the restrictions are quite severe and on the whole it's a lot less to program in, I imagine. That's necessary for implementing PyPy, but generally if you want fast compiled code that can interact with Python, you'd use Cython (which is targeted at CPython extensions and supports pretty much all of Python seamlessly) or write code in one of the more common languages that can do this. And if you just want fast, compiled code... well, RPython may be more pleasant than e.g. C, but still, I don't see a significant advantage here (at least none that would warrant the effort to create a usable, stable language).
发布评论
评论(5)
为什么我想直接用 RPython 编写?
Python 代码和运行 PyPy 看起来简单多了。
我为什么要写C代码?
编写 Python 并用 C 实现 PyPy 似乎要简单得多
为什么我要编写汇编代码?
编写 Python 并用 C 实现 PyPy 以及用汇编器实现 C 似乎要简单得多。
我想这确实是海龟一直往下走。
为什么我要停止使用最方便的语言并改用不太方便的语言?
放弃一门好语言有什么价值?
Why would I want to write directly in RPython?
It seems so much simpler to Python code and run PyPy.
Why would I want to write C code?
It seems so much simpler to write Python and have PyPy be implemented in C
Why would I want to write assembler code?
It seems so much simpler to write Python and have PyPy implemented in C and C implemented in Assembler.
I guess it really is turtles all the way down.
Why would I want to stop using the most convenient language and switch to a less convenient language?
What's the value in giving up a nice language?
我不能代表其他人,但我个人对使用 RPython 作为通用语言非常感兴趣。回答一些其他人的问题:
为什么?因为 Cython 很难弄清楚如何使用。如果您没有正确地放入大量棘手的类型声明,则不会获得任何加速。使用 RPython,它会运行得很快,或者根本不会运行。
使用 PyPy 可以提供良好的加速,但目前还不如 RPython。
RPython 可能是获得超快、有点 Python 风格的代码的好方法。 这里有一个示例来帮助您入门。不幸的是,我不知道有任何大型项目可以做到这一点。
I can't speak for everyone else, but I personally am extremely interested in using RPython as a general-purpose language. To answer some other people's questions:
Why? Because Cython is a pain to figure out how to use. If you don't put in a lot of tricky type declarations just right, you don't get any speedup. With RPython, it will run fast or it won't run at all.
Using PyPy offers a good speedup, but currently not nearly as much as RPython.
RPython might be a good way to get super-fast, somewhat Pythonic code. Here's an example to help you get started. I'm not aware of any large projects to do this, unfortunately.
是的,已经有一个项目使用 PyPy 的翻译工具链来使用 RPython 创建独立的可执行文件和库。它称为 RPythonic。
Yes, there is already a project to use the translation tool chain of PyPy to create standalone executables and libraries using RPython. It is called RPythonic.
通用 RPython 不会是 CPython 和 PyPy 的竞争对手。它甚至不是 Cython 之类的竞争对手。
为什么?因为RPython 不是Python!! RPython 只是一种与 Python 共享某些语法的语言;足以让 Python 解释器执行 RPython 代码,但是您不能获取 Python 代码并将其编译为 RPython。
为了使 RPython 能够静态类型化和编译(实际上,具有静态类型推断)而添加的对 Python 的限制非常严格,以至于完全改变了该语言。如果您想编写 RPython 程序,您必须预先决定并使用 RPython 编写。你不能用 Python 编写一个程序,然后决定将其编译为 RPython,你甚至不能稍微调整一个实际的 Python 程序以使其成为 RPython。普通的 Python 代码与普通的 RPython 代码完全不同;编写 RPython 与编写 Java 或 C# 更相似。
因此,如果您想用 Python 编写通用程序,但又希望它们运行得更快,那么 RPython 几乎无法为您提供帮助。这就是 PyPy 的 Python 解释器试图填补的空白。
如果你想用较低级别的编译语言编写通用程序,因为你需要你的程序运行得比 Python 更快,那么有现有的非常成熟的语言和库,比如 Java 或 C#。
使用 RPython 进行编码的原因是为了做一些由 RPython 特别做得更好的事情。就像编写解释器一样,您可以向其中添加垃圾收集器和 JIT 编译器,而无需手动编写它们! 这里 RPython 表现出色,是的,我对更精致、更可用的 RPython 解释器编写环境非常感兴趣。但作为一种通用编程语言,用于编写不会特别受益于 RPython 特性的程序,要使其能够与已经更好地发挥这一作用的现有语言竞争,需要付出巨大的工作量。例如,它现在甚至几乎没有标准库(因为几乎没有一个 Python 的扩展标准库可以在 RPython 中使用)。
A general purpose RPython would not be a competitor for CPython and PyPy. It wouldn't even be a competitor for things like Cython.
Why? Because RPython is not Python!! RPython is merely a language which shares some syntax with Python; enough that a Python interpreter can execute RPython code, but you cannot take Python code and compile it as RPython.
The restrictions on Python that are added to enable RPython to be statically typed and compiled (indeed, to have static type inference) are so severe that they completely change the language. If you want to write an RPython program, you have to decide to do so up front and write it in RPython. You can't write a program in Python and then decide to compile it as RPython, and you can't even tweak a realistic Python program a bit to make it RPython. Normal Python code is nothing like normal RPython code; writing RPython is more similar to writing Java or C#.
So if you want to write general programs in Python but you want them to go faster, RPython has very little to offer you. That's the niche PyPy's Python interpreter is trying to fill.
If you want to write general programs in a lower level compiled language because you need your program to run faster than Python, then there are existing very mature languages and libraries for that, like Java or C#.
The reason to code in RPython would be to do something that is particularly made better by RPython. Like writing interpreters to which you can add garbage collectors and JIT compilers without having to write them by hand! Here RPython shines, and yes I would be very interested in a more polished and usable RPython interpreter-writing environment. But as a general purpose programming language for writing programs that don't particularly benefit from RPython's specialities, it would simply be a monstrous amount of work to get it to the point where it could compete with existing languages that already fill that role better. It barely even has a standard library now (because almost none of Python's extensive standard library is usable in RPython), for example.
从表面上看,限制相当严格,而且总的来说,我想编程的地方要少得多。这对于实现 PyPy 是必要的,但通常如果您想要可以与 Python 交互的快速编译代码,您可以使用 Cython (它针对 CPython 扩展并无缝支持几乎所有的 Python),或者用一种更常见的语言编写代码来实现这一点。如果你只是想要快速、编译的代码......那么,RPython 可能比 C 更令人愉快,但是,我仍然没有看到这里的显着优势(至少没有一个可以保证努力创建一个可用的、稳定的)语言)。
From the looks of it, the restrictions are quite severe and on the whole it's a lot less to program in, I imagine. That's necessary for implementing PyPy, but generally if you want fast compiled code that can interact with Python, you'd use Cython (which is targeted at CPython extensions and supports pretty much all of Python seamlessly) or write code in one of the more common languages that can do this. And if you just want fast, compiled code... well, RPython may be more pleasant than e.g. C, but still, I don't see a significant advantage here (at least none that would warrant the effort to create a usable, stable language).