I enjoyed a relatively recent James Bennett, erm, broadside “Litestar is worth a look”. Broadside is probably too strong a term but gives you a sense of the tone. His post discusses why one should consider an alternative Python based HTTP serving engine, Litestar, as a productive modern framework. In particular, he got in a few healthy shots at a couple of my faves FastAPI and pydantic.
You save this as app.py, run with litestar run or hand it directly to the ASGI server of your choice, and it launches a web application. You go to /greet?name=Bob and it replies “Hi, Bob!”. Leave out the name parameter and it responds with an HTTP 400 telling you the name parameter is required.
So what. Big deal. The FastAPI Evangelism Strike Force will be along soon to bury you under rocket-ship emoji while explaining that FastAPI does the same thing but a million times better. And if you’re a Java person used to Spring, or a .NET person used to ASP.NET MVC, well, there’s nothing here that’s new to you; you’ve had this style of annotation/signature-driven framework for years (and in fact one thing I like about Litestar is how often it reminds me of the good parts of those frameworks). And did anyone tell you FastAPI does this, too! 🚀🚀🚀🚀🚀🚀🚀🚀🚀
But there are a lot of things that make Litestar stand out to me in the Python world. I’m going to pick out three to talk about today, and one of them is hiding in plain sight in that simple example application.
Here’s my summarization of his three points:
- Scalable management of route specification and organization
- Decoupling from Pydantic for schema validation and serialization/deserialization which enables …
- Application of SQLAlchemy, best of breed in the Python ecosystem, for database integration
The entire blog post is well worth reading and reasonably argued. Litestar won’t immediately become the first thing I reach for when building an HTTP backend. However, Bennett succeeded in provoking me to at least consider exploring Litestar for some future projects just to understand the tradeoffs and the developer experience. Robust alternatives are always good to know about. His closing graf captures the intent and outcome.
I could go on for a lot longer listing things I like about Litestar, and probably wind up way too far into my own subjective preferences, but hopefully I’ve given you enough of a realistic taste of what it offers that, next time you’re about to build a Python web app, you might decide to reach for 💡⭐ to carry you to the moon 🚀🚀🚀.