stats(nums_iterable) returning (total, count, maximum) from a possibly-one-shot iterable by materializing it once into a tuple first — the defensive move when you must traverse twice. Return (0, 0, None) for an empty input.stats(x * 2 for x in range(3))
(6, 3, 4)
The generator was captured once, then analyzed.
data = tuple(nums_iterable) up front.
Then sum/len/max safely on the tuple.