The -S option to python is defined by the documentation as “Disable the import of the module site and the site-dependent manipulations of sys.path that it entails.” I’ve found that python startup on my machine is more than twice as fast, sometimes much more, when I use this option. For example, on one (slow) machine:
$ time python -c 'print "hello"'
hello
python -c 'print "hello"' 0.14s user 0.03s system 85% cpu 0.204 total
$ time python -Sc 'print "hello"'
hello
python -Sc 'print "hello"' 0.02s user 0.01s system 73% cpu 0.038 total
That’s a 5.3x speedup. And it seems to work fine, at least with the scripts I’ve tried. What are the disadvantages to using it?
It’s probably not a good idea. Among other things, it means that the site-packages directory won’t be added to the path, so you won’t be able to import anything but the standard lib modules:
You can look at
site.pyyourself to see what it’s doing. It’s just a module in the regular library directory. At least on my system, it looks like it does four main things:quitandhelp)The first one is probably the most critical, as mentioned above. The second could be important for doing string I/O depending on your system’s locale settings (i.e., you may get errors if the default encoding isn’t correctly set). The third is probably not that important. The last one could be important if you like to have per-user path customizations (letting users have their own personal library directories, etc.).