dict.has_key(x) versus 'x in dict'

skip at pobox.com skip at pobox.com
Thu Dec 7 09:03:05 EST 2006


    >> I will admit that way back when (maybe 8 yrs ago) I actually did this
    >> in a piece of frequently executed code that's been stable for a
    >> looong time.  I have no idea why I might have written it that way.
    >> Brain fart I suppose.  I only noticed my mistake a couple months ago
    >> during a trip into the containing function for some other stuff.
    >> Man, was I embarrassed...

    Hendrik> why? - the main point is actually that the code worked, and was
    Hendrik> stable - that should make you proud, not embarrassed.  that
    Hendrik> there is far too much emphasis on doing things the quickest way
    Hendrik> - as long as it works, and is fast enough, its not broken, so
    Hendrik> don't fix it...

That's the rub.  It wasn't fast enough.  I only realized that had been a
problem once I fixed it though.

Skip



More information about the Python-list mailing list