Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe add a compile function #183

Open
facelessuser opened this issue Apr 8, 2022 · 0 comments
Open

Maybe add a compile function #183

facelessuser opened this issue Apr 8, 2022 · 0 comments
Labels
P: maybe Pending approval of low priority request. skip-triage Tells bot to not tag a new issue with 'triage'. T: feature Feature.

Comments

@facelessuser
Copy link
Owner

Wcmatch caches patterns, but for instance, it doesn't cache pattern expansion. So if a pattern uses something like {1..100}, you'd get 100 patterns cached, so the expansion would still happen every time, but the parsing of each pattern would not. We currently do this because we don't want someone filling memory with massive cache entries. So, there is always a little overhead when calling a fnmatch.match or a glob.globmatch calls, more so if you are using braces or splitting with |

It may be nice though, to pre-compile a match that can be used over and over again. Once compiled, you could call it with very little overhead. Something like:

matcher = glob.compile('**/*.txt', flags=glob.GLOBSTAR)
matcher.match('folder.file.txt')
@facelessuser facelessuser added T: feature Feature. P: maybe Pending approval of low priority request. skip-triage Tells bot to not tag a new issue with 'triage'. labels Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P: maybe Pending approval of low priority request. skip-triage Tells bot to not tag a new issue with 'triage'. T: feature Feature.
Projects
None yet
Development

No branches or pull requests

1 participant