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)
| 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 | """ |