diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2001-06-06 06:24:38 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2001-06-06 06:24:38 (GMT) |
commit | b5d4d2a7d53f8c2926fd3004aeba0b8b38a3d111 (patch) | |
tree | f0a72d769fd1ecb88bbd37f5d89be2413479d140 /Lib/glob.py | |
parent | 3d10b34b9c027d1e1c5613a4b1d80be4d31fb47a (diff) | |
download | cpython-b5d4d2a7d53f8c2926fd3004aeba0b8b38a3d111.zip cpython-b5d4d2a7d53f8c2926fd3004aeba0b8b38a3d111.tar.gz cpython-b5d4d2a7d53f8c2926fd3004aeba0b8b38a3d111.tar.bz2 |
Patch #409973: Speedup glob.glob, add fnmatch.filter.
Diffstat (limited to 'Lib/glob.py')
-rw-r--r-- | Lib/glob.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Lib/glob.py b/Lib/glob.py index eeb6bdd..d5e508a 100644 --- a/Lib/glob.py +++ b/Lib/glob.py @@ -18,7 +18,9 @@ def glob(pathname): else: return [] dirname, basename = os.path.split(pathname) - if has_magic(dirname): + if not dirname: + return glob1(os.curdir, basename) + elif has_magic(dirname): list = glob(dirname) else: list = [dirname] @@ -43,12 +45,9 @@ def glob1(dirname, pattern): names = os.listdir(dirname) except os.error: return [] - result = [] - for name in names: - if name[0] != '.' or pattern[0] == '.': - if fnmatch.fnmatch(name, pattern): - result.append(name) - return result + if pattern[0]!='.': + names=filter(lambda x: x[0]!='.',names) + return fnmatch.filter(names,pattern) magic_check = re.compile('[*?[]') |