2009/9/17 Kent Johnson <ken...@tds.net>: > 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 >
Hmm... I obviously didn't sprinkle round enough hints of my uncertainty in the matter. I did, however, suggest that the OPer profiles both to check. I was assuming that would cover all the bases. Even if I do provide full, working functions, I'm not going to spoon feed anyone a "fait accomplis". I'm still learning too... hence the 'tutor' mailing list, not the 'expert' mailing list. Perhaps I was wrong on which would be faster, to be honest, I don't care that much: if anyone is really worried about speed, they're using the wrong language. Perhaps that's the wrong stance to take, but again, I don't care that much. I always try to make it clear when I'm not certain about a matter. If I have ever misled anyone, I can only apologise. -- Rich "Roadie Rich" Lovely There are 10 types of people in the world: those who know binary, those who do not, and those who are off by one. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor