The best Python

The best Python is no Python.

Python is a horrendously slow language, too high-level for your own good, and it hides a lot of stuff you should definitively be conscious about if you want to be a better programmer.

It's also the language that I love.

I could write Python all day. The syntax is just so good. Like a good friend said, Python is pseudocode that runs .

Having said that, I think you should use Python responsibly, that is: use Python to write scripts that call C libraries that were optimized by people smarter than you.

(Or, for short scripts, directly leverage bytes or stuff like that. As an example, here is a script I like very much.)

So is it what I did for Red Dwarf? Well... no.

Python and friends

But hey, at least I was aware of that and I tried to write as less Pythonslop as possible. Functions over methods. Smart branching. Early returns.

And it is also because I was aware of that (I'm not boring you without a reason) that I choosed to delegate as much work as possible to "something else".

That something else being Caddy .

The Caddy case

Caddy is a fantastic reverse proxy.

It's fast (because it's not written in Python duh), it's got a lot of features, can do HTTP2/3 no problem, and it handles cert renewal for you (!).

I love Caddy. If you use Red Dwarf, I recommend you do it with Caddy.

Stuff like CORS, static serve, etc, try to do it in Caddy first.

The only problem I see is compression: Caddy can do it just fine in most algorithms that matter, and Datastar benefits immensely from compression, but it's said in secret cult circles that you can squeeze extra performance by carefully tuning the compression window, which is (afaik) not yet possible in Caddy.

So that's the deal. Let incoming requests be handled by a fast, performing reverse proxy, and when requests go through, handle business logic with cool Python scripts.

Deal?

The boring stuff (with Python)

Finally, I'm going to tell you what the real requirement for Red Dwarf was.

One of the worst things that can happen to a tool you use is when you're too afraid to change it .

And what I discovered is that the code for a server is kinda boring .

So I tried to make it as short as possible. Not golfed, readable, but short and expressive. 600 lines of Python. Readable.

So if you're missing a feature, want to twist stuff or inspect a bug, you can go take a look by yourself.

Take the snake by the horns, if you will.