bpo-31324: Optimize support._match_test() (#4421)
* Rename support._match_test() to support.match_test(): make it
public
* Remove support.match_tests global variable. It is replaced with a
new support.set_match_tests() function, so match_test() doesn't
have to check each time if patterns were modified.
* Rewrite match_test(): use different code paths depending on the
kind of patterns for best performances.
Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index 9871a28..ce01c8c 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -257,12 +257,12 @@
if isinstance(test, unittest.TestSuite):
self._list_cases(test)
elif isinstance(test, unittest.TestCase):
- if support._match_test(test):
+ if support.match_test(test):
print(test.id())
def list_cases(self):
support.verbose = False
- support.match_tests = self.ns.match_tests
+ support.set_match_tests(self.ns.match_tests)
for test in self.selected:
abstest = get_abs_module(self.ns, test)