<br>You'd probably better explain in English which things truly need to be compared with what.  Right now, your first version is, I believe, an O(n^4) algorithm, which is extremely expensive, while your second (set-based) version appears to be O(n^3), which is quite a bit better, but still not stellar.<br>
<br>I suspect you could just flatten your list of lists of numbers down to a single list of numbers, and then extract the maximum and minimum numbers using the min and max functions, and then compare those two results within tolerance, but further discussion should determine if that's correct.  If this would give the correct result, it should be an O(n) algorithm, which is vastly faster.<br>
<br>The main question in my mind is: Are the inner lists (in your list of lists) things that need to be somehow compared as a unit against all the other such units, or are they all the same kind of thing that just happens to be in an unnecessarily structured representation right now.<br>
<br><div class="gmail_quote">On Thu, Jul 28, 2011 at 12:11 AM, Christian Doll <span dir="ltr"><<a href="mailto:dollebolle@gmail.com">dollebolle@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hello,<br>
<br>
i have e little performance problem with my code...<br>
<br>
i have to compare many lists of very much floats. at moment i have<br>
nested for-loops<br>
<br>
for a in range( len(lists) ):<br>
    for b in range( a+1 , len(lists) ):<br>
        for valuea in lists[a]:<br>
            equal=False<br>
            for valueb in lists[b]:<br>
                if inTolerance( valuea , valueb , 1.0): # inTolerance<br>
is an own function, which checks if the difference of valuea and<br>
valueb is not more then 1.0%<br>
                    equal=True<br>
                    break<br>
    if equal:<br>
        print a , "and" , b , "are equal"<br>
<br>
i found a version with set which is faster, but i cannot assign an<br>
tolerance (%)<br>
for a in range( len(lists) ):<br>
    for b in range( a+1 , len(lists) ):<br>
        if len( lists[a] ) ==<br>
len( set( lists[a] ).intersection( set( lists[b] ) ) ):<br>
            print a , "and" , b , "are equal"<br>
<br>
have you an idea how i can change my code, that i can compare many<br>
lists of floats with a tolerance in percentage very fast?<br>
<br>
(sorry for my bad englisch ;-) )<br>
<br>
thanks<br>
christian<br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>