Skip to content

smheidrich/comparison-of-python-startup-accelerators

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

Releases

No releases published

Packages

No packages published

Languages