Django 与 PyPy

发布于 2024-10-08 18:56:44 字数 50 浏览 3 评论 0原文

将 Django 与 PyPy 一起使用有什么原因吗? 我读到 PyPy 提高了性能。

Are there some reasons of using Django with PyPy?
I read PyPy increases perfomance.

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

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

发布评论

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

评论(3

策马西风 2024-10-15 18:56:44

不太可能。 Django 应用程序几乎总是 I/O 密集型,通常是因为数据库连接。 PyPy 对此根本没有帮助,即使它是纯粹兼容的(我不确定它是否是)。

Unlikely. A Django application is almost always I/O-bound, usually because of the database connection. PyPy wouldn't help with that at all, even if it was purely compatible (which I'm not sure it is).

許願樹丅啲祈禱 2024-10-15 18:56:44

视情况而定。

PyPy 确实提高了 PyPy 基准测试套件中所有基准测试的性能。目前这只是模板渲染,但没有人提交任何其他内容。然而,可以安全地假设性能关键代码会更快(尤其是在进行一些调整之后)。

兼容性方面的数据库有点问题,因为只有 sqlite 可以工作,而且速度很慢(尽管有一个分支可以修复它)。例如,人们还报告了 pg8000 与 sqlalchemy 一起工作,但我没有第一手经验。

干杯,
菲哈尔

Depends.

PyPy does improve performance for all benchmarks that are in the PyPy's benchmark suite. This is only template rendering for now, but noone submitted anything else. It's however safe to assume that performance critical code will be faster (especially after some tuning).

Compatibility-wise databases are a bit of an issue, because only sqlite is working and it's slow (there is a branch to fix it though). People also reported pg8000 working with sqlalchemy for example, but I don't have a first-hand experience.

Cheers,
fijal

如日中天 2024-10-15 18:56:44

我用 PyPy + Django 做了一些实验。有两个主要问题:

  • 大多数数据库适配器和其他第三方模块无法使用 PyPy 进行编译(即使 wiki 说可以)。

  • 我认为一台服务器可能会受益于 JIT 编译,因为它在某些请求中进行了奇特的计算,但内存占用量不断增加,也许是因为 JIT 存储的跟踪结果对每个请求来说都是唯一的,因此从未被重用?

理论上,如果您的服务器正在进行有趣的计算、使用纯 python 模块并且内存中有大量对象(因为 PyPy 在某些情况下可以减少每个对象使用的内存),那么 PyPy 可能会获胜。否则,JIT 的较高内存要求将成为一个障碍,因为它减少了内存中缓存的机会,并且可能需要额外的服务器来运行足够的服务器进程。

I have done some experimentation with PyPy + Django. There are two main issues:

  • Most database adaptors and other third-party modules cannot be compiled with PyPy (even when the wiki says they can).

  • One server I thought might benefit from JIT compilation because it did a fancy calculation in some requests had an increasing memory footprint, perhaps because the JIT was storing traces that turned out to be unique to each request so were never reused?

Theoretically PyPy might be a win if your server is doing interesting calculations, uses pure-python modules, and has large numbers of objects in-memory (because PyPy can reduce the memory used per-object in some circumstances). Otherwise the higher memory requirements of the JIT will be an impediment because it reduces opportunities for in-memory caching and may require extra servers to run enough server processes.

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