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

skip at pobox.com skip at pobox.com
Sat Dec 9 13:21:09 EST 2006


>>>>> "Hendrik" == Hendrik van Rooyen <mail at microcorp.co.za> writes:

    Hendrik> <skip at pobox.com> wrote:
    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.

    Hendrik> LOL - this is kind of weird - it was working, nobody
    Hendrik> complained, you fiddled with it to make it faster, (just
    Hendrik> because you could, not because you had to, or were asked to),
    Hendrik> it became faster, and then, suddenly, retrospectively, it
    Hendrik> became a problem ????

No, I think you misunderstand.  I was poking around in that function for
other reasons, saw the "k in d.keys()" and realized that the wrong way to
write it.  Rewrote it and noticed the performance increase.  What's so weird
about that?

Skip



More information about the Python-list mailing list