Python startup time
Wow, Python startup time is worse than I thought. Here’s some data from a fast Ubuntu box. I ran all commands a bunch of times to warm caches.
$ time python2.7 -c 1
real 0m0.015s
user 0m0.012s
sys 0m0.000s
$ time python3.2 -c 1
real 0m0.026s
user 0m0.024s
sys 0m0.000s
$ strace python2.7 -c 1 2>&1 | wc -l
856
$ strace python3.2 -c 1 2>&1 | wc -l
1429
$ echo >| /tmp/empty.py
$ time python2.7 -O /tmp/empty.py
real 0m0.042s
user 0m0.032s
sys 0m0.008s
$ time python2.7 -O /tmp/empty.py
real 0m0.044s
user 0m0.032s
sys 0m0.008s
$ time python2.7 -S empty.py
real 0m0.004s
user 0m0.004s
sys 0m0.000s
$ strace python2.7 -S -c 1 2>&1 | wc -l
301
That last one’s a bit of a winner; -S means “don’t load site modules” and comes from this ExpertsExchange discussion. I lose /usr/local/lib; if I manually add that in my script I get my minimal libgit2 program down to 6ms.