MCPcopy
hub / github.com/celery/celery / regen

Function regen

celery/utils/functional.py:182–191  ·  view source on GitHub ↗

Convert iterator to an object that can be consumed multiple times. ``Regen`` takes any iterable, and if the object is an generator it will cache the evaluated list on first access, so that the generator can be "consumed" multiple times.

(it)

Source from the content-addressed store, hash-verified

180
181
182def regen(it):
183 """Convert iterator to an object that can be consumed multiple times.
184
185 ``Regen`` takes any iterable, and if the object is an
186 generator it will cache the evaluated list on first access,
187 so that the generator can be "consumed" multiple times.
188 """
189 if isinstance(it, (list, tuple)):
190 return it
191 return _regen(it)
192
193
194class _regen(UserList, list):

Callers 14

test_listMethod · 0.90
gMethod · 0.90
test_dequeMethod · 0.90
test_reprMethod · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
_maybe_groupFunction · 0.90

Calls 1

_regenClass · 0.85

Tested by 8

test_listMethod · 0.72
gMethod · 0.72
test_dequeMethod · 0.72
test_reprMethod · 0.72