Which is Faster in Python and Why?

jc = {}; m = []
x = [ [1,2,3,4,5,6,7,8,9],[..],.......] # upwards of 10000 entries

def mcountb():
    for item in x:
        b = item[:]; b.sort(); bc = 0
        for bitem in b: bc += int(bitem)
        try: m = jc[bc]
        except: m = []
        if m.count(b) == 0:
             m.append(b); jc[bc]=m

def binm()
    for item in x:
        b = item[:]; b.sort(); bc = 0
        for bitem in b: bc += int(bitem)
        try: m = jc[bc]
        except: m = []
        if not b in m:
            m.append(b); jc[bc]=m

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

Reply via email to