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

Lie Ryan lie.1296 at gmail.com
Wed Oct 27 07:07:39 CEST 2010


On 10/26/10 05:53, Guido van Rossum wrote:
>> 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
> advantages.
> 
>> 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.

except the max(a, b) is an attempt to find square hole to fit the square
peg, and the max([a]) attempt is trying to find a round peg to fit the
round hole with.




More information about the Python-ideas mailing list