Re: Which is faster? (if not b in m) or (if m.count(b) 0)

2006-02-22 Thread Farel
Thank you, Peter!  Please understand, I was attempting to get more info
on the WHY x is faster than y...  from those with more experience.
Timer cannot give me that info.

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


Re: Which is faster? (if not b in m) or (if m.count(b) 0)

2006-02-17 Thread Farel
Great observations... Changing for lists to tuples would make sorting
unnecessary...

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


Re: Which is faster? (if not b in m) or (if m.count(b) 0)

2006-02-17 Thread Farel
Well, I could, but I was looking for answers from persons more
experienced in the ways of Python then myself

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


Re: Which is faster? (if not b in m) or (if m.count(b) 0)

2006-02-17 Thread Farel
Tim, Are you saying that:
 not (b in m)
is faster than:
b not in m


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


Re: Which is faster? (if not b in m) or (if m.count(b) 0)

2006-02-17 Thread Farel
Execellent, Kent. Thank you... and everyone too! I've learned much!

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


Which is faster? (if not b in m) or (if m.count(b) 0)

2006-02-14 Thread Farel

Which is Faster in Python and Why?

jc = {}; m = []
x = [ [1,2,3,4,5,6,7,8,9],[..],...] # upwards of 1 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