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

Delaney, Timothy (Tim) tdelaney at avaya.com
Sun Dec 10 18:23:53 EST 2006


Hendrik van Rooyen wrote:

> So the weirdness for me was that you called a piece of perfectly good
> working code a problem, just because it was faster after you fixed
> it, even though you had no prior knowledge of the offending line that
> was doing the right thing, albeit slowly. - I would only have called
> such a piece of code a problem if I had been inundated with prior
> requests to fix the slow-running dog... 

I agree with Skip - it was a problem, and should have been fixed (then
extensively tested, including performance tests to find the new limits
...).

It's a "problem" IMO because it will scale badly. Chances are you'll
never see it scale badly in the lab, unless you *really* try. But then
some customer goes and puts it into production in an environment you
hadn't considered, and suddenly you're running at 100% CPU continuously,
and end up losing data, failing to provide service, etc.

Tim Delaney



More information about the Python-list mailing list