Node.js has changed the JS world forever, So as a python developer at that time I thought hey why can’t we bring that architecture to python (we already had generators ), even though it was a bit late the asyncio feature was released on the 3.4 version.
So what does it do, compare to JS async/await statement
Let us see an example of how asyncio works in python
|
|
ok, so what happens when we run the program
|
|
Now we are seeing something that we have only seen in a browser console. This is now officially supported in python 😌
So the heading was about Quart?
Let’s get down with what Quart is, to be frank, its an exact fork of Flask the minimal web framework for python, for the past few months I have been working on a project to do some System-Level I/O stuff,
It has proved its worth on an Event-Driven system ,the benchmark was so promising and the performance is notable.
3X faster than flask to be exact with minimal response time’s (Tested with PostgreSQL)
Route | Request per second Flask | Request per second Quart | Latency Flask | Latency Quart |
---|---|---|---|---|
GET /films/995/ | 330.22 | 1160.27 | 60.55 | 17.23 |
GET /films/ | 99.39 | 194.58 | 201.14 | 102.76 |
POST /reviews/ | 324.49 | 1113.81 | 61.60 | 18.22 |
The only thing to keep in mind is that it can’t do heavy computation similar to JS. But could make a hell of an HTTP server and has build-in support for
HTTP/1.1 requests streaming.
Websockets.
HTTP/2 server push.
HTTP/3 (I think it’s already in work)
If you plan to migrate your old flask codebase to Quart it’s easy as pie, See the Code for yourself.
|
|
So guys why not give it a trie, plus don’t try to block the event loop 😝
Visit https://gitlab.com/pgjones/quart for more info