bpo-31324: Optimize support._match_test() by vstinner · Pull Request #4421 · python/cpython (original) (raw)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that (char not in '?*[]') is more readable, and this function doesn't seem to be a performance bottleneck, there is no need to optimize it. Moreover, I just added a cache to not recompile patterns if set_match_tests() is called twice with the same patterns.
It seems like the compilation to a giant regex is slow, but I don't think that we can optimize this much, and again, I don't think that it's worth it. My main usage of many patterns is when I use test.bisect, but test.bisect only uses full test identifiers and so should use set().contains.