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

Method expand

Lib/test/test_itertools.py:89–99  ·  view source on GitHub ↗
(it, i=0)

Source from the content-addressed store, hash-verified

87 def pickletest(self, protocol, it, stop=4, take=1, compare=None):
88 """Test that an iterator is the same after pickling, also when part-consumed"""
89 def expand(it, i=0):
90 # Recursively expand iterables, within sensible bounds
91 if i > 10:
92 raise RuntimeError("infinite recursion encountered")
93 if isinstance(it, str):
94 return it
95 try:
96 l = list(islice(it, stop))
97 except TypeError:
98 return it # can't expand it
99 return [expand(e, i+1) for e in l]
100
101 # Test the initial copy against the original
102 dump = pickle.dumps(it, protocol)

Callers 1

test_expandMethod · 0.45

Calls 2

listClass · 0.85
expandFunction · 0.85

Tested by

no test coverage detected