Serialisation cost of Python functions #2152
-
Hi ! I'm trying to find some side-project to use both python and rust. Sorry in advance if the question does not fit here. I found this thread regarding the performance overhead (compared to CPython) #1607 but I'm not sure if this would really be a big issue here. use actix_web::{web, App, HttpRequest, HttpServer, Responder};
async fn greet(req: HttpRequest) -> impl Responder {
// Call python function with GET arguments...
// for instance fetch data from Postgresql and return it
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.route("/", web::get().to(greet))
.route("/{name}", web::get().to(greet))
})
.bind(("127.0.0.1", 8080))?
.run()
.await
} My idea would be to write the higher level code in a FastAPI fashion that would then create the app with the routes. But I'm not sure about the performance of executing the Python logic for the endpoint. Thanks ! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hey! Welcome, and pleased to hear you're interested in trying out PyO3 for a new project.
To be honest, I think doing this is a really interesting concept that I'd wondered about playing with myself in the past (never found the time). How about looking at it the other way around: pure-Python webservers (maybe with a sprinkle of C at the core) are very common in industry and have sufficient performance for many applications. Writing the framework in Rust and then letting users write the endpoints in Python seems like a very interesting concept. You might also be interested in https://github.com/litmus-web/litmus and https://github.com/litmus-web/Pyre-Writeup |
Beta Was this translation helpful? Give feedback.
-
Hi! Thank you for your answer! Glad to know that the idea is not too far fetched :). I'll have a look at the links! |
Beta Was this translation helpful? Give feedback.
Hey! Welcome, and pleased to hear you're interested in trying out PyO3 for a new project.
To be honest, I think doing this is a really interesting concept that I'd wondered about playing with myself in the past (never found the time). How about looking at it the other way around: pure-Python webservers (maybe with a sprinkle of C at the core) are very common in industry and have sufficient performance for many applications. Writing the framework in Rust and then letting users write the endp…