[Python-Dev] Let's stop eating exceptions in dict lookup

Raymond Hettinger raymond.hettinger at verizon.net
Mon May 29 23:02:25 CEST 2006

> On Mon, May 29, 2006 at 12:20:44PM -0700, Raymond Hettinger wrote:
>> > I've finally come around to writing a patch that stops dict lookup from
>> > eating all exceptions that occur during lookup, like rare bugs in user
>> > __eq__() methods.
>> Is there a performance impact?
> I believe that this patch is good anyway, because I consider my (and
> anybody's) debugging hours worth more than a few seconds of a
> long-running process.  You get *really* obscure bugs this way.
> I would also point out that this is the kind of feature that should not
> be traded off for performance, otherwise we'd loose much of the point of
> Python.  IMHO.
> As it turns out, I measured only 0.5% performance loss in Pystone.

Please run some better benchmarks and do more extensive assessments on the 
performance impact.

The kind of obscure bug you're trying to kill does not affect 99.9% of Python 
users; however, loss of performance will affect everyone.  This is arguably the 
most actively exercised part of the Python and should not be changed without 
carefully weighing purity vs practicality.

FWIW, I applied a similar patch to set objects in Py2.5 so that they wouldn't 
eat exceptions.  So, I'm truly sympathetic to the cause.  However, dicts are 
much more critical.  There needs to be a careful judgement based on measurements 
and assessments of whether there are real benefits for everyday Python users.


More information about the Python-Dev mailing list