Steven D'Aprano wrote: > Except that using has_key() means making an attribute lookup, which takes > time.
I was going to say that, but doesn't 'in' require an attribute lookup of some sort too, of __contains__ or whatever? has_key is probably now just a wrapper around that, so it would be one more attribute lookup. What's the difference in performance between attribute lookups from Python code and from the internal C code? > Now, if you want to argue that the difference between 0.3 microseconds > and 0.2 microseconds is insignificant, I'd agree with you -- for a single > lookup. But if you have a loop where you're doing large numbers of > lookups, using in will be a significant optimization. I meant that it's (usually) insignificant, and barely larger than the usual inaccuracy due to my system's load (I'm tired; what's the word for that?). -- -- http://mail.python.org/mailman/listinfo/python-list