On Thu, Sep 17, 2009 at 11:01 AM, steve <st...@lonetwin.net> wrote:
> On 09/17/2009 06:04 PM, Kent Johnson wrote:
>>
>> On Thu, Sep 17, 2009 at 8:06 AM, Rich Lovely<roadier...@googlemail.com>
>>  wrote:
>>>
>>>  2009/9/17 Rayon<evosw...@hotmail.com>:
>>>>
>>>>  I need to find the max and min value from some floats in a array:
>>
>>>  Depending on the size of the array, there's two methods:  Using the
>>>  max and min builtin functions, which will be faster for small arrays,
>>>  or hand-coding a single pass function, which might be faster for
>>>  arrays above a certain size.
>>
>> Why do you expect a hand-coded function to scale better? I would
>> expect them both to be O(n).
>>
> I guess what Rich meant was, a hand-coded function to get /both/ min and max
> in a single pass would be faster on large arrays (as done in the posted
> minmax2() function) than calling min() and max() individually (which would
> imply 2 passes).

Yes, that is my understanding of his statement. My question is, why
would it be faster only on large arrays? I expect the time of both
methods to scale linearly with the size of the array. Two fast passes
might be faster than one slow pass regardless of the size of the
array.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to