python/nondist/sandbox/statistics statistics.py, 1.8, 1.9
Update of /cvsroot/python/python/nondist/sandbox/statistics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18972 Modified Files: statistics.py Log Message: Minor tweak to reduce the number of comparisons and passes over the data. Index: statistics.py =================================================================== RCS file: /cvsroot/python/python/nondist/sandbox/statistics/statistics.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** statistics.py 29 Feb 2004 09:12:28 -0000 1.8 --- statistics.py 4 Mar 2004 05:17:50 -0000 1.9 *************** *** 105,110 **** while True: pivot = random.choice(data) ! pcount = data.count(pivot) ! over, under = [], [] uappend, oappend = under.append, over.append for elem in data: --- 105,110 ---- while True: pivot = random.choice(data) ! pcount = 0 ! under, over = [], [] uappend, oappend = under.append, over.append for elem in data: *************** *** 113,116 **** --- 113,118 ---- elif elem > pivot: oappend(elem) + else: + pcount += 1 if n < len(under): data = under
participants (1)
-
rhettingerīŧ users.sourceforge.net