"I want to be upfront that this blog post is for me to write down some thoughts that I have on the idea of rewriting the Python Launcher for Unix from Rust to pure Python. This blog post is not meant to explicitly be educational or enlightening for others, but I figured if I was going to write this down I might as well just toss it online in case someone happens to find it interesting. Anyway, with that caveat out of the way..."
"I started working on the Python Launcher for Unix in May 2018. At the time I used it as my Rust starter project and I figured distributing it would be easiest as a single binary since if I wrote it in Python how do you bootstrap yourself in launching Python with Python? But in the intervening 7.5 years, a few things have happened:"
"I compared the Rust version to the Python version on my machine running Fedora 43 by running "py --version". If I give Rust an optimistic number by picking its average lower-bound and Python a handicap of picking its average upper-bound, we get: 3 ms for Rust (333 Hz) 33 ms for Python (30 Hz) So 11x slower for Python. But when the absolute performance is fast enough to let you run the Python Launcher for Unix over 30 times a second, does it actually matter?"
Development of the Python Launcher for Unix began in May 2018 and was implemented in Rust to enable distribution as a single binary. A quick pure-Python prototype implemented $VIRTUAL_ENV support, .venv detection in parent directories, and PATH searching for the newest Python in 72 lines. Benchmarking on Fedora 43 measured roughly 3 ms for the Rust binary and 33 ms for the Python prototype when running py --version, about an 11× slowdown for Python. The absolute Python latency still permits more than thirty launches per second, making the switch feasible if that performance meets deployment requirements.
Read at Tall, Snarky Canadian
Unable to calculate read time
Collection
[
|
...
]