MCPcopy Index your code
hub / github.com/python/cpython / filter

Function filter

Lib/fnmatch.py:53–67  ·  view source on GitHub ↗

Construct a list from those elements of the iterable NAMES that match PAT.

(names, pat)

Source from the content-addressed store, hash-verified

51
52
53def filter(names, pat):
54 """Construct a list from those elements of the iterable NAMES that match PAT."""
55 result = []
56 pat = os.path.normcase(pat)
57 match = _compile_pattern(pat)
58 if os.path is posixpath:
59 # normcase on posix is NOP. Optimize it away from the loop.
60 for name in names:
61 if match(name):
62 result.append(name)
63 else:
64 for name in names:
65 if match(os.path.normcase(name)):
66 result.append(name)
67 return result
68
69
70def filterfalse(names, pat):

Callers 15

test_filterMethod · 0.90
test_caseMethod · 0.90
test_sepMethod · 0.90
create_archiveFunction · 0.70
_convert_Method · 0.70
_old_convert_Function · 0.70
addMethod · 0.70
_find_link_targetMethod · 0.70
phase1Method · 0.70
_format_usageMethod · 0.70
_guess_delimiterMethod · 0.70

Calls 4

matchFunction · 0.85
normcaseMethod · 0.80
_compile_patternFunction · 0.70
appendMethod · 0.45

Tested by 3

test_filterMethod · 0.72
test_caseMethod · 0.72
test_sepMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…