How to execute two “aggregate” functions (like sum) concurrently, feeding them from the same iterator?
Let’s consider how to apply two aggregate functions to the same iterator, which we can only exhaust once. The initial attempt (which hardcodes sum and max for brevity, but is trivially generalizable to an arbitrary number of aggregate functions) might look like this: def max_and_sum_buffer(it): content = list(it) p = sum(content) m = max(content) return … Read more