GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — pathlib match, full_match and glob take exponential time on short patterns because glob.translate skips fnmatch's atomic-group rewrite · Issue #159717 · python/cpython Open Labels stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-pathlibtriagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug report
import fnmatch, glob, os, tempfile, time from pathlib import Path, PurePosixPath pat = '*a' * 8 + '*b' # 18 characters print('translate:', glob.translate(pat)) def t(f): s = time.perf_counter(); f(); return f'{time.perf_counter() - s:.4f} s' for n in (28, 36, 44, 52): name = 'a' * n print(n, "full_match", t(lambda: PurePosixPath(name).full_match(pat)), '| match', t(lambda: PurePosixPath(name).match(pat)), '| fnmatchcase', t(lambda: fnmatch.fnmatchcase(name, pat))) with tempfile.TemporaryDirectory() as d: open(os.path.join(d, 'a' * 44), 'w').close() print('Path.glob ', t(lambda: list(Path(d).glob(pat)))) print('glob.glob ', t(lambda: glob.glob(pat, root_dir=d))) Python 3.14.8 (3.15.0 gives the same figures within noise): The time grows roughly as the binomial of the name length over the number of stars, so a few more characters in the name or one more First affected release is 3.13.0, where Cause, at the default branch: results.extend(fnmatch._translate(part, f'{not_sep}*', not_sep)[0]) Index Suggested fix: build each segment in CPython versions tested on:3.13, 3.14, 3.15 Operating systems tested on:Linux Linked PRsActivity
MetadataMetadataAssigneesLabelsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-pathlibtriagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |