Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django with PyPy

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

like image 543
Stan Avatar asked Dec 20 '10 14:12

Stan


People also ask

Does Django work with PyPy?

PyPy can run most code that runs in CPython. You can run popular frameworks like requests, Django, Flask, FastAPI. You can run tests in frameworks like Pytest. PyPy is available for Python versions 2.7, 3.7, 3.8 and 3.9.

Is PyPy as fast as C?

PyPy is a runtime interpreter that is faster than a fully interpreted language, but it's slower than a fully compiled language such as C.

Is PyPy faster than Python?

The results: Python needs, on average, 6.7 seconds to execute the code. PyPy needs 9.4 seconds for execution on average. Python is faster.

Can I run Python code in PyPy?

PyPy only supports one version of Python 2 and Python 3, which are PyPy 2.7 and PyPy 3.6. If the code that is executed in PyPy is pure Python, then the speed offered by PyPy is usually noticeable. But if the code contains C extensions, such as NumPy, then PyPy might actually increase the time.


2 Answers

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).

like image 182
Daniel Roseman Avatar answered Oct 14 '22 17:10

Daniel Roseman


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

like image 30
fijal Avatar answered Oct 14 '22 16:10

fijal