Both list and islice objects are iterable but why this difference in result.
r = [1, 2, 3, 4]
i1, i2 = tee(r)
print [e for e in r if e < 3]
print [e for e in i2]
#[1, 2]
#[1, 2, 3, 4]
r = islice(count(), 1, 5)
i1, i2 = tee(r)
print [e for e in r if e < 3]
print [e for e in i2]
#[1, 2]
#[]
The issue here is that
tee()needs to consume the values from the original iterator, if you start consuming them from the original iterator, it will be unable to function correctly. In your list example, the iteration simply begins again. In the generator example, it is exhausted and no more values are produced.This is well documented:
Source
Edit to illustrate the point in the difference between a list and a generator: