Standard Forth versus Python: a case study
bearophileHUGS at lycos.com
bearophileHUGS at lycos.com
Thu Oct 12 08:53:36 EDT 2006
Ian McConnell wrote:
> > If you can use Psyco and your FITS lines are really long (well, maybe
> > too much, the treshold if about >~3000 in my PC) you can use something
> > like this instead the builtin timsort:
> > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/466330
> > (To compute the median on a image line the median that uses sort is
> > probably better in most cases, expecially if you use the built in sort
> > of numerical libraries.)
>
> sort() sorts all of the data, but you're only after one or two numbers, so
> the MODFIND method may be faster for the median:
The modified quicksort I have shown in the cookbook (466330) is O(n)
too, and it modifies the list in place, so you can apply it twice for
lists of even len.
Bye,
bearophile
More information about the Python-list
mailing list