[Python-Dev] Startup time

Jeff Epler jepler@unpythonic.net
Wed, 7 May 2003 13:30:26 -0500


On Wed, May 07, 2003 at 12:06:18PM -0500, Jeff Epler wrote:
> What about this line?  It seems to be the cause of a bunch of imports,
> including the sre stuff:
>     /* pythonrun.c */
>         PyModule_WarningsModule = PyImport_ImportModule("warnings");

With this *and* the unicode stuff removed, I see runtimes like this:
$ time ./python -S -c pass
real    0m0.008s
user    0m0.010s
sys     0m0.000s

and opens are nearly down to 2.2 levels:
$ strace -e open ./python -S -c pass 2>&1 | grep -v ENOENT | wc
     11      44     489
$ strace -e open /usr/bin/python -S -c pass 2>&1 | grep -v ENOENT | wc
      8      32     355
(the differences are libstdc++, libgcc_s, and librt)

With *just* the import of warnings removed, I get this:
$ time ./python -S -c pass
real    0m0.017s
user    0m0.010s
sys     0m0.010s
.. and the input of sre is back.  I guess it's used in both warnings.py
and encodings/__init__.py

Jeff