mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
gh-122288: Improve performances of fnmatch.translate
(#122289)
Improve performance of this function by a factor of 1.7x. Co-authored-by: Barney Gale <barney.gale@gmail.com>
This commit is contained in:
parent
14a05a8f43
commit
78cb377c62
4 changed files with 112 additions and 47 deletions
|
@ -312,7 +312,7 @@ def translate(pat, *, recursive=False, include_hidden=False, seps=None):
|
|||
if part:
|
||||
if not include_hidden and part[0] in '*?':
|
||||
results.append(r'(?!\.)')
|
||||
results.extend(fnmatch._translate(part, f'{not_sep}*', not_sep))
|
||||
results.extend(fnmatch._translate(part, f'{not_sep}*', not_sep)[0])
|
||||
if idx < last_part_idx:
|
||||
results.append(any_sep)
|
||||
res = ''.join(results)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue