[Python-Dev] 2.3 startup speed? (original) (raw)

Thomas Heller theller@python.net
Fri, 11 Jul 2003 17:20:19 +0200


Jeremy Hylton <jeremy@zope.com> writes:

On Fri, 2003-07-11 at 10:16, Fred L. Drake, Jr. wrote:

Perhaps, but... those imports only happen if it already looks like you're running from a build directory, so they don't impact the imports for an installed Python. You are so true. I just did fresh installs of 2.2.3 and 2.3 to see what happens when I run from an install Python. A nice minimal set of imports for 2.2.3: import site import os import posix import posixpath import stat import UserDict import copyreg import types import future There are a lot more for 2.3 (and each one costs more). import zipimport import site import os import posix import posixpath import stat import UserDict import copyreg import types import warnings import linecache import re import sre import srecompile import sre import sreconstants import sreparse import string import encodings import codecs import codecs import encodings.aliases import encodings.iso885915 We can blame the extra imports on three new features. The zip import feature requires the zipimport module. The warnings feature requires warnings, linecache, and re, where re is costly -- seven imports in total. The top-level "import re" was removed from warnings.py, but it doesn't make any difference. The routine that uses the re module is called from the top-level of the warnings module. The default file system encoding feature requires the encodings and codecs packages to be loaded. That's another five imports. Anyone want to drop warnings and encodings? <0.9 wink> Sure. There's another problem with these imports happening very early, it breaks py2exe, and maybe also McMillan installer because these imports happen before the import hook is installed.

Thomas