and I would point out that on my machine (GCC 6.3-based x86-64 Linux) the times are much closer
~ time python2 -c exit
real 0m0.014s
user 0m0.011s
sys 0m0.004s
vs.
~ time python3 -c exit
real 0m0.022s
user 0m0.018s
sys 0m0.004s
So for me it's more like an 8ms realtime difference, and four milliseconds are spent in the system either way.
python2 seems to do about 700 system calls (!) to start up and exit immediately, including enumerating things like gtk-2 and wxwidgets, which boggles the mind, but it is what it is.
python3 seems to do about 470 system calls, much less but still bonkers to my mind. Also weird that they take the same ~4ms in the kernel given that python3 calls into the kernel so much less.
My times on x86-64 Linux are similar to yours, but on the Windows Subsystem for Linux (which emulates the Linux kernel) it's a different story:
$ time python2 -c exit
real 0m0.111s
user 0m0.016s
sys 0m0.078s
$ time python3 -c exit
real 0m0.063s
user 0m0.016s
sys 0m0.047s
Python 3 is consistently ~twice as fast. Both seem slower, but this is on a small laptop so the absolute measurements may not be comparable. This is on Creators Update.
That's better yet - thanks for sharing! Most of my Python processes run for weeks at a go, so startup time isn't that important to me as long as it's not glacial. But 40ms (on my system) or 22ms (on yours) is totally acceptable for interactive shell usage.
Thanks for including the syscall counts. I know they'd been working to reduce that, but I hadn't seen how much progress they'd made yet. Are most of those to malloc() and open()?
It absolutely is. Consider that that means that python takes 2-3 frames to start up. I'm not sure one should or could reasonably consider that "slow" for interactive use.
python2 seems to do about 700 system calls (!) to start up and exit immediately, including enumerating things like gtk-2 and wxwidgets, which boggles the mind, but it is what it is.
python3 seems to do about 470 system calls, much less but still bonkers to my mind. Also weird that they take the same ~4ms in the kernel given that python3 calls into the kernel so much less.