>>> ================================ RESTART === >>> 0 30.4740708665 secs (Anton Vredegoor) >>> ================================ RESTART === >>> 0 30.4132625795 secs (Anton Vredegoor) >>> ================================ RESTART === >>> 0 30.4812175849 secs (Anton Vredegoor) >>>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++ import psyco, time def freq(L): D = {} for x in L: D[x] = D.get(x,0)+1 return D def test(): f = file('D:/m4000.txt') f.readline() L = [] for line in f: L.append(map(int,line.split())) q,w,e,r = map(freq,zip(*L)) sch,h = 0,{} for xk,xv in q.iteritems(): for yk,yv in w.iteritems(): if h.has_key(xk+yk): h[xk+yk] += xv*yv else: h[xk+yk] = xv*yv for xk,xv in e.iteritems(): for yk,yv in r.iteritems(): if h.has_key(-(xk+yk)): sch += h[-(xk+yk)]*xv*yv print sch t = time.clock() psyco.full() test() print time.clock() - t,"secs (Anton Vredegoor)" +++++++++++++++++++++++++++++++++++++++++++++++++++++++ PS The same PC: AMD Sempron +2600 (1.6 GHz); 512 MB RAM. -- http://mail.python.org/mailman/listinfo/python-list