Puff - A Framework for making it seamless to build a hybrid Rust/Python/Django application using greenlets and Tokio

45 points kyle-hanson

https://github.com/hansonkd/puff

Hello all, I wanted to share with you my experiment for the past few months. It's an attempt at unifying Rust and Python into a harmonious single framework with clear boundaries and safety. Puff has multi-node PubSub, WSGI, Redis, Postgres compatible Python libraries implemented in Rust built in.

The idea of Puff is that Python has some very mature web frameworks and ORMs like Django that can manage the database tables, generate Admin interfaces, and have lots and lots of documentation. So Puff wants to utilize those Python libraries, but provide a convenient way to optimize the critical part of the app without a bunch of tooling overhead. This framework provides structure to make this happen seamlessly.

Puff makes 100% of python packages and 100% of rust packages compatible with each other and only a line of code away.

At a high level, Puff runs python multiple concurrent functions on one thread using Greenlets and relies on Rusts' Tokio family of async functions to do any IO or blocking operations.

Puff can run an Axum server which can intercept requests in Rust before they make it to your WSGI application.

A killer feature of Puff is the powerful GraphQL engine. Puff's GraphQL interface allows you to return Django queries as SQL strings and offload all computation of the resulting data structures onto Tokio. Subscriptions with websockets are supported.

So far this is just an experiment, but I'm really excited about the potential. Rust and Python go together like peanut butter and jelly.