Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Doc/library/fnmatch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ module. See module :mod:`glob` for pathname expansion (:mod:`glob` uses
a period are not special for this module, and are matched by the ``*`` and ``?``
patterns.

Also note that :func:`functools.lru_cache` with the *maxsize* of 32768 is used to
cache the compiled regex patterns in the following functions: :func:`fnmatch`,
:func:`fnmatchcase`, :func:`filter`.

.. function:: fnmatch(filename, pattern)

Expand Down
2 changes: 1 addition & 1 deletion Lib/fnmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def fnmatch(name, pat):
pat = os.path.normcase(pat)
return fnmatchcase(name, pat)

@functools.lru_cache(maxsize=256, typed=True)
@functools.lru_cache(maxsize=32768, typed=True)
def _compile_pattern(pat):
if isinstance(pat, bytes):
pat_str = str(pat, 'ISO-8859-1')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
In :mod:`fnmatch`, the cache size for compiled regex patterns
(:func:`functools.lru_cache`) was bumped up from 256 to 32768, affecting
functions: :func:`fnmatch.fnmatch`, :func:`fnmatch.fnmatchcase`,
:func:`fnmatch.filter`.