smheidrich / comparison-of-python-startup-accelerators

Comparison of Python startup accelerator utilities/frameworks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Comparison of Python startup accelerators

It is sometimes claimed that there are more Python startup acceleration utilities than cells in the human body. Here I compare them all.

Did I miss one or do you have suggestions for other criteria? Feel free to open an issue!

Comparison

All of them employ the same basic principle: There is a server process which, when launched, does your application's expensive startup work (typically imports, but could be other things) and then runs in the background, waiting for clients. When a user launches your actual application, they're really launching a client which connects to this server. The server forks off a copy of itself which runs the "main" (i.e. non-init) part of your application, which launches much faster because all the init work is already done. The client's input and output streams as well as environment and CLI args are attached/forwarded to the server process so the experience is otherwise the same as running the application directly.

Name / URL Client written in Server written in Implicit server launch Association between script and preload state Reload on changes Packaging integration / entrypoints
Pyseidon πŸƒ C (but launched by a Python script β‡’ diminished speedup 🐌) 🐌 Python ❌ ❌ No automatic mechanism. User can manually select different server by setting env var ❌ ❌
quicken 🐌 Python 🐌 Python βœ… βœ… Associated by absolute path of top-level executed script βœ… Watches top-level script for changes βœ…
Python Preloaded 🐌 Python 🐌 Python βœ… βœ… Associated by sys.argv[0] of top-level executed script together with current working directory ❌ ❌

Hypothetical "perfect" accelerator

The "perfect" (IMO) Python accelerator utility would combine the best parts of each of the existing ones and add some extra features on top:

Name / URL Client written in Server written in Implicit server launch Association between script and preload state Reload on changes Packaging integration / entrypoints
Hypothetical perfect accelerator πŸƒ C or Rust, no launcher script or bash script if necessary πŸƒ C, Rust, or compiled Python (Mypyc, Cython, ...)1 βœ… βœ… Associated by absolute top-level script path together with path to Python executable (to handle venvs) βœ… Reload on any change in script or imported modules, e.g. using py-hot-reload (unless too bad for performance) βœ… (But again, no slow launcher script so probably no standard entrypoints)

1 If you're puzzled by what the benefit would be when it immediately executes slow Python anyway: The application's Python code might also have been compiled by Mypyc or Cython, in which case a server written in pure Python could end up causing most of the remaining startup delay.

About

Comparison of Python startup accelerator utilities/frameworks


Languages

Language:Python 100.0%