You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fnmatch translates shell patterns to regexes, using an LRU cache of 256 elements. The documentation doesn't mention the cache size, just "They cache the compiled regular expressions for speed.". Without this knowledge, it's possible to get pathologically bad performance by exceeding the cache size.
Please consider adding documentation of the cache size to the module documentation for fnmatch, along with a suggestion to use fnmatch.translate directly if you have more patterns than that.
In addition to documenting the cache size, consider a substantial increase to the limit. Compiled regex patterns tend to be very small. We can afford to have a lot of them (tens of thousands seems reasonable to me).
Regarding the suggested alternative, ISTM that calling translate() directly doesn't help much. For a cache miss, the overhead of the lru_cache() is very small relative to the work done by translate().
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: