Jeremy Sanders wrote: > Jeremy Sanders wrote: > >> Chaz Ginger wrote: >> >>> What would sets do for me over lists? >> It's faster to tell whether something is in a set or dict than in a list >> (for some minimum size). > > As a footnote, this program > > import random > num = 100000 > > a = set( range(num) ) > for i in range(100000): > x = random.randint(0, num-1) in a > > completes in less than a second, whereas > > import random > num = 100000 > > a = range(num) > for i in range(100000): > x = random.randint(0, num-1) in a > > takes a long time on my computer. > > Jeremy > Thanks Jeremy. I am in the process of converting my stuff to use sets! I wouldn't have thought it would have made that big a deal! I guess it is live and learn.
Peace, Chaz -- http://mail.python.org/mailman/listinfo/python-list