from future_builtins import zip
from collections import deque
from itertools import count

def ilen(it):
    cnt = count()
deque(zip(it, cnt), 0)
return next(cnt)
What's the shortest way to count the number of items in a generator/iterator?