[Python-Dev] _sre as part of python.dll
Barry A. Warsaw
Fri, 9 Aug 2002 10:44:36 -0400
>>>>> "Gordo" == Gordon McMillan <firstname.lastname@example.org> writes:
Gordo> In the 1.5.2 timeframe, most *startup* time was
Gordo> spent figuring out where to root sys.path (looking
Gordo> for the sentinel, deciding if this is a developer
Gordo> build, etc.). In crude experiments on my Linux
Gordo> box, I got rid of a few hundred system calls
Gordo> just by removing most of the intelligence from
Gordo> the getpath stuff.
I remember doing some similar testing probably around the Python 2.0
timeframe and found a huge speed up by avoiding the import of site.py
for largely the same reasons (avoiding tons of stat calls). It's not
always practical to avoid loading site.py, but if you can, you can get
a big startup win.
Gordo> So the lowest hanging fruit, I think, is to find some
Gordo> way of telling Python "don't be clever - just start
Gordo> here", and have it fallback to current behavior in
Gordo> the absence of that info.
That's what $PYTHONHOME is supposed to do. It's been a while since I
dug around in getpath.c, but setting $PYTHONHOME should set prefix and
exec_prefix unconditionally, even in the build directory.
(The comments in the file are abit little misleading. Step 1 could be
read as implying that $PYTHONHOME isn't consulted when looking for
build directory landmarks, but that's not the case: even for a build
dir search, $PYTHONHOME is trusted unconditionally.)