km wrote:
how abt this ?

N = len(IN)
for k  in range(N):
    for j in range(N):
        if j >= k:                 # or k <= j
            doSomething()

This has the root problem that the "if" statement is evaluated N*N times, which is ugly/slow O(N^2) behavior. My solution managed to reduce it by a constant multiplier, but several folks proposed a more elegant O(N) solution which was leaps & bounds faster.

-tkc



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to