Suppose I've written a Python script and I want to run it a lot, but it takes a long time to start up because of its dependencies. Perhaps the most obvious way to speed it up is to add a loop inside the program. A disadvantage of this strategy is that my commands to run the program are no longer regular shell commands, so I don't get completion, history, interspersion with other commands, etc. (unless I implement such features separately).
What I'd like to do is cache the running instance of the program: essentially, to daemonize it on its first run, and then have subsequent commands interact with the already running program. Is there a library that makes this daemonization and command-line interaction with the daemon process easy to implement? I only need it to work on Linux.