In Linux, or any other form of unix, os.execl and friends are a good choice for this — you just need to re-exec sys.executable with the same parameters it was executed with last time (sys.argv
, more or less) or any variant thereof if you need to inform your next incarnation that it’s actually a restart. On Windows, os.spawnl (and friends) is about the best you can do (though it will transiently take more time and memory than os.execl and friends would during the transition).