Incomparable abominations

Niki Spahiev spahievi at vega.bg
Tue Mar 25 14:35:59 EST 2003


3/25/2003, 6:05:17, Tim Peters wrote:

TP> [Niki Spahiev]
>> I do. It's easiest way to get point on the convex hull of point set.
>> (point === complex).

TP> Except that isn't true.  If Python compared complex numbers
TP> lexicographically (as it used to do), then the easiest way to get a point on
TP> the convex hull would be to do min(list_of_complex) or max(list_of_complex).
TP> Sorting isn't necessary for this, and would be far less efficient than the
TP> min/max ways.

Actually i used min (but point is min and sort crash the same way). Now i use:

def minll(a,b):
    if a.real < b.real:
        return a
    elif a.real > b.real:
        return b
    elif a.imag < b.imag:
        return a
    else:
        return b

pi = reduce(minll, complex_list)

ugly, but works on any python version.

Niki Spahiev






More information about the Python-list mailing list