Skip to main content

reduces startup and import times by maintaining a pool of python processes

Project description

python-module-launcher was a failed experiment in improving the startup performance of python programs. It was concerned with two things:

  • eliminate interpreter startup times

  • reduce module import times

Eliminating startup times is achieved by maintaining a pool of worker processes. Reducing module load times is achieved by importing modules immediately after a worker is spawned (python does not import modules that are already in sys.modules).

I ended up trying this approach because of a few small Qt dialogs that weren’t launching as fast as I would like them too. The results were an 100ms reduction in startup time (PySide is a hefty package to import). At that point I abandoned this project (there are a lot of unresolved issues such as handling return codes and proper shutdown)


Usage: python-module-launcher-2.7 [-hvdpws] socket [mod, ...]

  -h, --help           show this help message and exit
  -v, --version        show version and exit
  -d, --daemonize      run in background (default: no)
  -p, --pidfile        pid file to use if running as a daemon
  -w, --workers <num>  worker processes to start (default: 5)
  -s, --spare <num>    spare worker processes to maintain (default: 3)

  socket               location of AF_UNIX socket
  mod*                 modules to pre-import in every worker

  python-module-launcher-2.7 -f launcher.sock numpy PySide.QtCore PySide.QtGui
  echo -n "module" | nc -U launcher.sock

You can send the following commands to the unix socket:

file path/to/ arg1 arg2 ...
module arg1 arg2 ...
entrypoint name==0.1.0 console_scripts name arg1 arg2 ...


python-module-launcher is released under the terms of the New BSD License.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

module-launcher-0.1.0.tar.gz (4.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page