
On 23.06.2015 13:57, Sturla Molden wrote:
On 23/06/15 01:29, Gregory P. Smith wrote:
While I understand that Windows adds some overhead there, startup time for Python worker processes is high on all OSes.
No it is not.
A fork() will clone the process. You don't need to run any initialization code after that. You don't need to start a new Python interpreter -- you already have one. You don't need to run module imports -- they are already imported. You don't need to pickle and build Python objects -- they are already there. Everything you had in the parent process is ready to use the child process. This magic happens so fast it is comparable to the time it takes Windows to start a thread.
To be fair, you will nevertheless get a slowdown when copy-on-write kicks in while first using whatever was cloned from the parent. This is nothing which blocks execution, but slows down execution. That is no time which can directly be measured during the fork() call, but I would still count it into start up cost. regards, jwi