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

Function commonprefix

Lib/_pyrepl/fancycompleter.py:192–201  ·  view source on GitHub ↗

Return the common prefix of all 'names

(names)

Source from the content-addressed store, hash-verified

190
191
192def commonprefix(names):
193 """Return the common prefix of all 'names'"""
194 if not names:
195 return ''
196 s1 = min(names)
197 s2 = max(names)
198 for i, c in enumerate(s1):
199 if c != s2[i]:
200 return s1[:i]
201 return s1

Callers 4

test_commonprefixMethod · 0.90
global_matchesMethod · 0.70
attr_matchesMethod · 0.70
do_test_commonprefixMethod · 0.50

Calls 1

enumerateFunction · 0.85

Tested by 2

test_commonprefixMethod · 0.72
do_test_commonprefixMethod · 0.40

Used in the wild real call sites across dependent graphs

searching dependent graphs…