[Python-ideas] [Python-Dev] minmax() function returning (minimum, maximum) tuple of a sequence

Guido van Rossum guido at python.org
Mon Oct 25 20:53:40 CEST 2010

> Guido van Rossum wrote:
>> This should not require threads.
>> Here's a bare-bones sketch using generators:

On Mon, Oct 25, 2010 at 10:10 AM, Peter Otten <__peter__ at web.de> wrote:
> I don't think the generator-based approach is equivalent to what Lie Ryan's
> threaded code does. You are calling max(a, b) 99 times while Lie calls
> max(items) once.

True. Nevertheless, my point stays: you shouldn't have to use threads
to do such concurrent computations over a single-use iterable. Threads
too slow and since there is no I/O multiplexing they don't offer

> Is it possible to calculate min(items) and max(items) simultaneously using
> generators? I don't see how...

No, this is why the reduce-like approach is better for such cases.
Otherwise you keep trying to fit a square peg into a round hold.

--Guido van Rossum (python.org/~guido)

More information about the Python-ideas mailing list