Show More
@@ -2624,10 +2624,8 b' class _generatorset(object):' | |||
|
2624 | 2624 | gen: a generator producing the values for the generatorset. |
|
2625 | 2625 | """ |
|
2626 | 2626 | self._gen = gen |
|
2627 | self._iter = iter(gen) | |
|
2628 | 2627 | self._cache = {} |
|
2629 | 2628 | self._genlist = baseset([]) |
|
2630 | self._iterated = False | |
|
2631 | 2629 | self._finished = False |
|
2632 | 2630 | |
|
2633 | 2631 | def __contains__(self, x): |
@@ -2639,28 +2637,30 b' class _generatorset(object):' | |||
|
2639 | 2637 | if l == x: |
|
2640 | 2638 | return True |
|
2641 | 2639 | |
|
2642 | self._finished = True | |
|
2643 | 2640 | self._cache[x] = False |
|
2644 | 2641 | return False |
|
2645 | 2642 | |
|
2646 | 2643 | def __iter__(self): |
|
2647 |
if self._ |
|
|
2648 | # At least a part of the list should be cached if iteration has | |
|
2649 | # started over the generatorset. | |
|
2650 | for l in self._genlist: | |
|
2651 | yield l | |
|
2652 | ||
|
2653 | for item in self._consumegen(): | |
|
2654 | yield item | |
|
2644 | if self._finished: | |
|
2645 | for x in self._genlist: | |
|
2646 | yield x | |
|
2647 | return | |
|
2648 | ||
|
2649 | i = 0 | |
|
2650 | genlist = self._genlist | |
|
2651 | consume = self._consumegen() | |
|
2652 | while True: | |
|
2653 | if i < len(genlist): | |
|
2654 | yield genlist[i] | |
|
2655 | else: | |
|
2656 | yield consume.next() | |
|
2657 | i += 1 | |
|
2655 | 2658 | |
|
2656 | 2659 | def _consumegen(self): |
|
2657 | self._iterated = True | |
|
2658 | ||
|
2659 | 2660 | for item in self._gen: |
|
2660 | 2661 | self._cache[item] = True |
|
2661 | 2662 | self._genlist.append(item) |
|
2662 | 2663 | yield item |
|
2663 | ||
|
2664 | 2664 | self._finished = True |
|
2665 | 2665 | |
|
2666 | 2666 | def set(self): |
General Comments 0
You need to be logged in to leave comments.
Login now