Steven D'Aprano wrote: > > > Don't imagine, measure. > > Resist the temptation to guess. Write some test functions and time the two > different methods. But first test that the functions do what you expect: > there is no point having a blindingly fast bug.
Thats is absolutely correct. Although I think you do sometimes have to guess. Otherwise you would write multiple versions of every line of code. > > > But count passes through the list in C and is also very fast. Is that > faster or slower than the hashing code used by sets? I don't know, and > I'll bet you don't either. Sure. But if I'm not currently optimizing I would go for the method with the best behaviour, which usualy means hashing rather than searching. Since even if it is actualy slower - its not likely to be _very_ slow. Will McGugan -- http://www.willmcgugan.com "".join({'*':'@','^':'.'}.get(c,0) or chr(97+(ord(c)-84)%26) for c in "jvyy*jvyyzpthtna^pbz") -- http://mail.python.org/mailman/listinfo/python-list