我知道 Django、PyPy 和 Psycopg2 都可以正常工作,并且speed.pypy.org声称与 CPython 相比有很大的性能改进。有什么缺点吗?
2 回答
Library support. Not all libraries are compatible with PyPy.
Your best bet is to actually try running
pypy manage.py test
and see if it breaks. Then you know which dependencies need to be brought into line.http://reinout.vanrees.org/weblog/2011/06/06/django-and-pypy.html
Webservers
You can't use pypy with Apache. You need to use a pure-python webserver + nginx. You MAY get it working on uwsgi.
The PyPy wiki lists Django as compatible, but it doesn't go into great detail about how much of Django was tested. I am not aware of any major Django deployment that runs PyPy instead of CPython. A better question is why you'd want to switch to PyPy for a Django app, especially as Django has been extensively tested and deployed with CPython.
PyPy is good for tasks that are computationally intensive. Web apps are usually not. The Django benchmark they base their performance numbers off is essentially a template rendering benchmark which is a CPU intensive task. This is not representative of most web apps where the bottle neck tends to be I/O. As such, PyPy may not speed up your site as much as those graphs lead you to believe.