Do Not Cache an Exhausted Generator as a Reusable Stock List
A generator is consumed as it is iterated. Saving the generator object does not save a reusable copy of the rows it yields. A second report can see an empty result even though the first report saw records.
For global dropshipping data tools, warehousing and fulfillment readers should decide whether they need a stream or a reusable snapshot. This example materializes a tiny, fictional stream as a tuple.
def records():
yield ("A", 2)
yield ("B", 1)
stream = records()
assert list(stream) == [("A", 2), ("B", 1)]
assert list(stream) == []
cached = tuple(records())
assert list(cached) == [("A", 2), ("B", 1)]
assert list(cached) == [("A", 2), ("B", 1)]
assert cached[0] == ("A", 2)
print("5 checks passed")
Python's iterator documentation describes exhaustion. Five checks show consumption, the exhausted second read and repeated reads from the tuple.
Materialization uses memory and waits for the stream to finish. It is not automatically suitable for large exports. This example's rows are immutable tuples; a tuple containing mutable dictionaries would still require a separate ownership policy. No real stock, live connector or customer record was used in the local execution.

Computer workstations and printing equipment in a warehouse.
All rights reserved