与 CPython、Jython 和 IronPython 相比,PyPy 能提供什么?

发布于 2024-07-14 10:54:17 字数 156 浏览 6 评论 0原文

从我在博客上看到和读到的内容来看,PyPy 是一个非常雄心勃勃的项目。 与它的兄弟姐妹(CPython、Jython 和 IronPython)相比,它会带来哪些优势? 是速度、跨平台兼容性(包括移动平台)、在没有 GIL 的情况下使用 c 扩展的能力,还是这更多的是关于可以做什么的技术练习?

From what I have seen and read on blogs, PyPy is a very ambitious project. What are some advantages it will bring to the table over its siblings (CPython, Jython, and IronPython)? Is it speed, cross-platform compatibility (including mobile platforms), the ability to use c-extensions without the GIL, or is this more of a technical exercise on what can be done?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

飘落散花 2024-07-21 10:54:17

PyPy 实际上是两个项目:

  • 一个解释器编译器工具链,允许您在 RPython(Python 的静态子集)中编写解释器,并为 JVM、.NET(等)独立编译跨平台解释器
  • 在 RPython 中实现 Python

这些两个项目可以实现很多事情。

  • 在 Python 中维护 Python 比在 C 中维护 Python 容易得多
  • 从单个代码库中,您可以生成在 JVM、.NET 上独立运行的 Python 解释器 - 而不是拥有多个稍微不兼容的实现
  • 编译器工具链的一部分包括一个实验性 JIT 生成器(现在是第五个版本,并且开始工作得很好) - 目标是 JITed PyPy 运行速度比 CPython
  • 实验基本语言功能要容易得多- 比如删除 GIL、更好的垃圾收集、集成 stackless 等等

因此,PyPy 确实有很多令人兴奋的理由,而且它终于开始兑现其所有承诺。

PyPy is really two projects:

  • An interpreter compiler toolchain allowing you to write interpreters in RPython (a static subset of Python) and have cross-platform interpreters compiled standalone, for the JVM, for .NET (etc)
  • An implementation of Python in RPython

These two projects allow for many things.

  • Maintaining Python in Python is much easier than maintaining it in C
  • From a single codebase you can generate Python interpreters that run on the JVM, .NET and standalone - rather than having multiple slightly incompatible implementations
  • Part of the compiler toolchain includes an experimental JIT generator (now in its fifth incarnation and starting to work really well) - the goal is for a JITed PyPy to run much faster than CPython
  • It is much easier to experiment with fundamental language features - like removing the GIL, better garbage collection, integrating stackless and so on

So there are really a lot of reasons for PyPy to be exciting, and it is finally starting to live up to all its promises.

似梦非梦 2024-07-21 10:54:17

最重要的功能当然是 JIT 编译器。 在 CPython 中,文件被编译为字节码 (.pyc) 或优化字节码 (.pyo),然后进行解释。 使用 PyPy,它们将被编译为本机代码。 PyPy 还包含 Stackless Python 补丁,其中包括令人印象深刻的 功能(tasklet 序列化、轻线程等)

The most important feature is of course the JIT compiler. In CPython files are compiled to bytecode (.pyc) or optimized bytecode (.pyo) and then interpreted. With PyPy they will be compiled to native code. PyPy also includes Stackless Python patches, including it's impressive features (tasklet serialization, light threads etc.)

阳光的暖冬 2024-07-21 10:54:17

如果 Python 获得真正的 JIT 我认为它会一样快与任何其他实现一样。

优点是更容易实现新功能。 今天通过观察图书馆就可以看到这一点。 通常模块首先用 Python 编写,然后翻译成 C。

In case that Python gets a real JIT I think it's going to be as fast as any other implementation.

The advantage is that it's much easier to implement new features. One can see this today by observing the library. Often modules are written in Python first and then translated into C.

ι不睡觉的鱼゛ 2024-07-21 10:54:17

跨平台兼容性

cross-platform compatibility

Yes

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文