def truncate(it, n):
    cache = [next(it) for i in range(n)]
index = 0
for val in it:
    val, cache[index] = cache[index], val
index = (index + 1) % n
yield val
All but the last N elements of iterator in Python