[New-bugs-announce] [issue31324] support._match_test() used by test.bisect is very inefficient
STINNER Victor
report at bugs.python.org
Fri Sep 1 11:11:02 EDT 2017
New submission from STINNER Victor:
support._match_test() uses a nested loop calling fnmatch.fnmatchcase(). This function creates a temporary regular expression object. The cache of the re module works around the performance... if the length of support.match_tests fits into the cache. But when the list is longer, the function becomes dead slow...
def _match_test(test):
global match_tests
if match_tests is None:
return True
test_id = test.id()
for match_test in match_tests:
if fnmatch.fnmatchcase(test_id, match_test):
return True
for name in test_id.split("."):
if fnmatch.fnmatchcase(name, match_test):
return True
return False
Maybe we should build a giant regex matching test_id at each, but cache the regex since support.match_tests can be modified anytime. I implemented this once, but I lost the code :-)
Currently, it's possible to match 3 things:
* test method name: test_exit
* test class name: SysModuleTest
* full test id: test.test_sys.SysModuleTest.test_exit
It's also possible to use "*" joker character in a test name. I would like to keep these convenient CLI.
----------
messages: 301122
nosy: haypo, serhiy.storchaka
priority: normal
severity: normal
status: open
title: support._match_test() used by test.bisect is very inefficient
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31324>
_______________________________________
More information about the New-bugs-announce
mailing list