From f5b468830c1088598dcf75f05c3fdc0e4c0fe829 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 21 Mar 2024 21:53:47 +0200 Subject: [PATCH] gh-117134: Microoptimize glob() for include_hidden=True --- Lib/glob.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/glob.py b/Lib/glob.py index 473502c67336f9..d59641195a1c41 100644 --- a/Lib/glob.py +++ b/Lib/glob.py @@ -104,8 +104,8 @@ def _iglob(pathname, root_dir, dir_fd, recursive, dironly, def _glob1(dirname, pattern, dir_fd, dironly, include_hidden=False): names = _listdir(dirname, dir_fd, dironly) - if include_hidden or not _ishidden(pattern): - names = (x for x in names if include_hidden or not _ishidden(x)) + if not (include_hidden or _ishidden(pattern)): + names = (x for x in names if not _ishidden(x)) return fnmatch.filter(names, pattern) def _glob0(dirname, basename, dir_fd, dironly, include_hidden=False):