[Patches] [ python-Patches-921466 ] Reduce number of open calls on startup

SourceForge.net noreply at sourceforge.net
Tue Mar 23 02:30:55 EST 2004


Patches item #921466, was opened at 2004-03-22 19:10
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=921466&group_id=5470

Category: Core (C code)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Martin v. Löwis (loewis)
Assigned to: Nobody/Anonymous (nobody)
Summary: Reduce number of open calls on startup

Initial Comment:
This patch uses sys.path_importer_cache to reduce the
number of open calls, in the following way:
- if the value in path_importer_cache is None, it stats
the path to find out whether the file exists
- it then puts True/False into path_importer_cache
- if the value in path_importer_cache is False, the
path entry is skipped on all imports
- if the value is True, the stat call is skipped, and
open calls for files in the directory are made.

On Linux, this reduces the number of open calls for an
empty script from 343 to 263. The startup-time (for 100
interpreter invocations) goes down by one percent (from
0.0819s to 0.08113s per invocation).

----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2004-03-23 02:30

Message:
Logged In: YES 
user_id=80475

I am surprised that making 25% fewer open calls doesn't save
more than 1% in startup time.

One other thought, I wonder if the timing of these changes
is affected by the OS keeping recently loaded files in
buffers so that disk access time not included.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=921466&group_id=5470



More information about the Patches mailing list