MCPcopy Create free account
hub / github.com/celery/celery / regen

Function regen

celery/utils/functional.py:184–193  ·  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

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

Calls 1

_regenClass · 0.85