[Patches] [ python-Patches-409973 ] glob.glob speedups

noreply@sourceforge.net noreply@sourceforge.net
Tue, 05 Jun 2001 23:27:07 -0700


Patches item #409973, was updated on 2001-03-20 01:57
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=409973&group_id=5470

Category: library
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Rob W.W. Hooft (hooft)
Assigned to: Nobody/Anonymous (nobody)
Summary: glob.glob speedups

Initial Comment:
A lot of the time spent by glob.glob on large
directories is spent doing os.path.normcase(). Half of
this can be saved by normcasing the pattern only once,
and on unix the whole normcase call can be left out.

This patch attempts to optimize globbing even a bit
more by delegating the fnmatching of a list of file
names to a new function fnmatch.filter, which allows us
to move a few more lookups outside of the file name
loop.

Furthermore, an optimization is added to glob.glob
calls that do not contain any directory specifications,
saving a round of os.path.join calls.

Speedups of the pattern '*.py?' in the python lib
directory range
from a factor of 2 with directory specification to a
factor of 5 without directory specifications.

Unfortunately there is no test_glob regression test,
but I did my best to verify that nothing changed in my
calls.

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

>Comment By: Martin v. Löwis (loewis)
Date: 2001-06-05 23:27

Message:
Logged In: YES 
user_id=21627

Committed as glob.py 1.10 and fnmatch.py 1.12.


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

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