Does itertools.product evaluate its arguments lazily?
The following never prints anything in Python 3.6 from itertools import product, count for f in product(count(), [1,2]): print(f) Instead, it just sits there and burns CPU. The issue seems to be that product never returns an iterator if it's over an infinite space because it evaluates the full product first. This is surprising given that the product is supposed to be a generator. I would have expected this to start counting up (to infinity), something like the behavior of this generator (taken directly from the docs ): for tup in ((x,y) for x in count() for y in [1,2]): print(tup) But whereas