All Questions
6 questions
1
vote
2
answers
275
views
using zip(*tuple_iterator) without consuming the tuple_iterator at this line
I have a tuple_iterator : Iterator[Tuple[A, B]] and I want to get an iterator_tuple: Tuple[Iterator[A], Iterator[B]]
this can in principle be done using iterator_a, iterator_b = zip(*tuple_iterator)
...
15
votes
2
answers
2k
views
Is Python `list.extend(iterator)` guaranteed to be lazy?
Summary
Suppose I have an iterator that, as elements are consumed from it, performs some side effect, such as modifying a list. If I define a list l and call l.extend(iterator), is it guaranteed ...
4
votes
1
answer
1k
views
In python, can I lazily generate copies of an iterator using tee?
I'm trying to create an iterator which lazily creates (potentially infinitely many) copies of an iterator. Is this possible?
I know I can create any fixed finite number of copies by simply doing
from ...
15
votes
2
answers
10k
views
Lazy map function in Python
Is there a way of making map lazy? Or is there another implementation of it built-in in Python?
I want something like this to work:
from itertools import count
for x in map(lambda x: x**2, count()):...
6
votes
2
answers
515
views
Feeling stupid while trying to implement lazy partitioning in Python
I am trying to implement lazy partitioning of an iterator object that yields slices of the iterator when a function on an element of the iterator changes values. This would mimick the behavior of ...
4
votes
2
answers
2k
views
If a python iterator returns iterable objects, how can I chain those objects into one big iterator?
I'll give a simplified example here. Suppose I have an iterator in python, and each object that this iterator returns is itself iterable. I want to take all the objects returned by this iterator and ...