4 ms·
Usual use would be "translate pattern once, compile it and then match 1000 file names against it".
by dom0 10y ago
Usual use would be "translate pattern once, compile it and then match 1000 file names against it".
- orf 10y agoAhh yes, it's cached in fnmatchcase. It's pretty fast as well, <10µs for a basic match.
- bluetech 10y agoA cache without any eviction! Probably should not expose `fnmatch` to the network where the pattern varies.
- dom0 10y agoThe RE engine here is only used as a fast VM; so the pathological cases from the article should still apply. So apart from the memory use issues there's also that.
- orf 10y agoIt should be updated with a functools.lru_cache decorator I think.
- benhoyt 10y agoThat's an old version of Python source from a mirror. It uses functools.lru_cache with a maxsize of 256 now: https://github.com/python/cpython/blob/fcfe80ec2592fed8b3941c79056a8737abef7d3b/Lib/fnmatch.py#L38 https://github.com/python/cpython/blob/fcfe80ec2592fed8b3941...
- js2 10y agoGah, thanks for the proper link. I should've double checked (and realized it since no updates in 8 years is unlikely).