PyPK wrote: > Yep that improved the speed by about 50% now it takes about 10 secs > instead of 24 seconds..Thanks much. I guess that is the best we could > do right.It would be really helpful if I could get it less than 5 > seconds. Any suggestions on that?? > Things to try: * in-lining the min and max expressions * depending on the distribution of e, it may be faster to catch KeyErrors
def search1(m): box = {} for r,row in enumerate(m): for c,e in enumerate(row): try: minc, minr, maxc, maxr = box[e] box[e] = ( c < minc and c or minc, r < minr and r or minr, c > maxc and c or maxc, r > maxr and r or maxr) except KeyError: box[e] = (c, r, c, r) return box Michael -- http://mail.python.org/mailman/listinfo/python-list