[Python-Dev] Startup time (original) (raw)

Jeremy Hylton jeremy@zope.com
16 May 2003 15:07:53 -0400


On Fri, 2003-05-16 at 15:00, Skip Montanaro wrote:

mal> FWIW, I've removed the re usage from encodings/init.py.

mal> Could you check whether this makes a difference in startup time mal> now? Well... Not really, but it's not your fault. site.py imports distutils.util which imports re. It does a fair amount of regex compiling, some at the module level, so deferring "import re" may take a couple minutes of work. Hang on...

I don't think you need to do anything to distutils. In the case we care about (an installed Python) distutils.utils isn't imported. Check this code in site.py:

Append ./build/lib. in case we're running in the build dir

(especially for Guido :-)

XXX This should not be part of site.py, since it is needed even when

using the -S option for Python. See http://www.python.org/sf/586680

if (os.name == "posix" and sys.path and os.path.basename(sys.path[-1]) == "Modules"): from distutils.util import get_platform s = "build/lib.%s-%.3s" % (get_platform(), sys.version) s = os.path.join(os.path.dirname(sys.path[-1]), s) sys.path.append(s) del get_platform, s

Jeremy