diff options
author | Raymond Hettinger <python@rcn.com> | 2011-10-20 16:22:10 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2011-10-20 16:22:10 (GMT) |
commit | db848035627f7ead50e5dea0016da25e242fe724 (patch) | |
tree | 2847370825df71388e9348260d4dcb187d7e12ea /Lib/fnmatch.py | |
parent | cd9fdfd652cdaca959b1c5d4cddf60d90a331b47 (diff) | |
download | cpython-db848035627f7ead50e5dea0016da25e242fe724.zip cpython-db848035627f7ead50e5dea0016da25e242fe724.tar.gz cpython-db848035627f7ead50e5dea0016da25e242fe724.tar.bz2 |
Simplify calls in fnmatch.
Diffstat (limited to 'Lib/fnmatch.py')
-rw-r--r-- | Lib/fnmatch.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/fnmatch.py b/Lib/fnmatch.py index 726fbe5..f446769 100644 --- a/Lib/fnmatch.py +++ b/Lib/fnmatch.py @@ -35,9 +35,9 @@ def fnmatch(name, pat): pat = os.path.normcase(pat) return fnmatchcase(name, pat) -@functools.lru_cache(maxsize=250) -def _compile_pattern(pat, is_bytes=False): - if is_bytes: +@functools.lru_cache(maxsize=250, typed=True) +def _compile_pattern(pat): + if isinstance(pat, bytes): pat_str = str(pat, 'ISO-8859-1') res_str = translate(pat_str) res = bytes(res_str, 'ISO-8859-1') @@ -49,7 +49,7 @@ def filter(names, pat): """Return the subset of the list NAMES that match PAT.""" result = [] pat = os.path.normcase(pat) - match = _compile_pattern(pat, isinstance(pat, bytes)) + match = _compile_pattern(pat) if os.path is posixpath: # normcase on posix is NOP. Optimize it away from the loop. for name in names: @@ -67,7 +67,7 @@ def fnmatchcase(name, pat): This is a version of fnmatch() which doesn't case-normalize its arguments. """ - match = _compile_pattern(pat, isinstance(pat, bytes)) + match = _compile_pattern(pat) return match(name) is not None |