Do iterators save memory in Python?
问题 I don't quite understand how iterators have memory in Python. >>> l1 = [1, 2, 3, 4, 5, 6] >>> l2 = [2, 3, 4, 5, 6, 7] >>> iz = izip(l1, l2) We still require O(min(l1, l2)) memory as we need to load the lists l1 and l2 in memory. I thought one of the main uses of iterators was to save memory - yet it does not seem to be useful here. Similarly, the code below is unclear to me: >>> l1 = ( n for n in [1, 2, 3, 4, 5, 6] ) >>> l2 = ( n for n in [2, 3, 4, 5, 6, 7] ) >>> iz = izip(l1, l2) We need to