I have the following code
from itertools import product
from time import sleep
def slowrange(n,t):
for i in range(n):
sleep(t)
yield i
for n,w in product(slowrange(5,0.2),"AB"):
print(n,w)
since in the itertools.product doc says that:
This function is roughly equivalent to the following code, except that the actual implementation does not build up intermediate results in memory
i would expect that i would see two lines with 0 A \n 0 B then 0.2 seconds later i would see the following iteration, however, that does not occur, after 1s all the iterations are printed, if i use the following function instead of itertools.product, it does perform the desired behavior:
def product(itertor1,iterator2):
for s in iterator1:
for f in iterator2:
yield s,f
So, what's going on?, is this a bug?, it is something wrong in the docs?