MCPcopy Create free account
hub / github.com/EntilZha/PyFunctional / cache

Method cache

functional/pipeline.py:202–221  ·  view source on GitHub ↗

Caches the result of the Sequence so far. This means that any functions applied on the pipeline before cache() are evaluated, and the result is stored in the Sequence. This is primarily used internally and is no more helpful than to_list() externally. delete_lineage

(self, delete_lineage=False)

Source from the content-addressed store, hash-verified

200 return self.to_list()
201
202 def cache(self, delete_lineage=False):
203 """
204 Caches the result of the Sequence so far. This means that any functions applied on the
205 pipeline before cache() are evaluated, and the result is stored in the Sequence. This is
206 primarily used internally and is no more helpful than to_list() externally. delete_lineage
207 allows for cache() to be used in internal initialization calls without the caller having
208 knowledge of the internals via the lineage
209
210 :param delete_lineage: If set to True, it will cache then erase the lineage
211 """
212 if len(self._lineage) == 0 or self._lineage[-1] == transformations.CACHE_T:
213 if not isinstance(self._base_sequence, list):
214 self._base_sequence = list(self._base_sequence)
215 self._lineage.apply(transformations.CACHE_T)
216 else:
217 self._base_sequence = list(self._evaluate())
218 self._lineage.apply(transformations.CACHE_T)
219 if delete_lineage:
220 self._lineage = Lineage(engine=self.engine)
221 return self
222
223 def head(self):
224 """

Callers 8

__getitem__Method · 0.95
lenMethod · 0.95
to_listMethod · 0.95
tabulateMethod · 0.95
csvMethod · 0.80
csv_dict_readerMethod · 0.80
jsonlMethod · 0.80
test_cacheMethod · 0.80

Calls 3

_evaluateMethod · 0.95
LineageClass · 0.90
applyMethod · 0.80

Tested by 1

test_cacheMethod · 0.64