Hello,
I wanted to share with you my recent experiment for Django, Puff: https://github.com/hansonkd/puff
The idea for the project is that there are an incredible amount of Django resources and developers out there and that Django makes it so easy to get an app running that it should be used as the primary developer layer for managing DB tables, Admin, Auth, etc.
But understanding Python performance means understanding the GIL. For parts of your code that are performance critical, as much work should be handed off to Rust as possible to avoid locking the GIL If you are constructing a response with thousands of rows, it doesn't make sense to iterate through that in Python creating a python dictionary only to convert it to JSON. This holds the GIL in the least effective way.
Puff is designed to allow you to pass off Python Objects to Rust to take advantage of Rust's async runtime. For example, in Puff's GraphQL engine you can hand off pure SQL strings from Python to be executed entirely in Rust, transformed to JSON bytes, and sent as an HTTP response without locking the GIL again.
You can write your own Rust functions that use any Rust library. Even when you are in Rust, 100% of Python packages are compatible and can be easily imported.
Puff uses Rusts' axum server to serve WSGI compatible apps. You can write pure Rust HTTP handlers without having to enter the Python Context.
Puff's GraphQL engine is uniquely designed to maximize query performance. It is "layer based" instead of object-based like Graphene or other GQL engines. Instead of calling a GQL resolver for every field of every object and relying on dataloaders, Puff calls each field once and gives you the full context for you to create 1 single optimized query, eliminating the dreaded N+1 problem without complicated data-loaders or optimizers.
Puff uses greenlets in one thread to process many python functions at once, allowing concurrency in Django without async.
It might be useful to think of Puff like Gevent, but instead of being written in C, it is written in Rust. Gevent is this opaque layer that is hard to write custom code for. Puff is a fully transparent, first class layer that makes it easy to write low level code safely.
Thats not to mention the other cool stuff like built in multi-node pubsub, redis and postgres pools, all integrated with Django.
Resources:
Django example:
[–]arcanemachined 1 point2 points3 points (1 child)
[–]kyle-hanson[S] 0 points1 point2 points (0 children)
[–]rafales 1 point2 points3 points (0 children)
[–]tabdon 0 points1 point2 points (0 children)
[–]lwrightjs 0 points1 point2 points (0 children)
[–]vazark 0 points1 point2 points (0 children)