def compat_tee(iterable):
 def gen(next, data={}, cnt=[0]):
  dpop = data.pop
  for i in itertools.count():
   if (i == cnt[0]):
    item = data[i] = next()
    cnt[0] += 1
   else:
    item = dpop(i)
   (yield item)
 next = iter(iterable).next
 return (gen(next), gen(next))

def compat_tee ( iterable ) : def gen ( next , data = { } , cnt = [ 0 ] ) : dpop = data . pop for i in itertools . count ( ) : if ( i == cnt [ 0 ] ) : item = data [ i ] = next ( ) cnt [ 0 ] += 1 else : item = dpop ( i ) ( yield item ) next = iter ( iterable ) . next return ( gen ( next ) , gen ( next ) )
return two independent iterators from a single iterable .