A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2006-May/065399.html below:

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

[Python-Dev] Let's stop eating exceptions in dict lookup [Python-Dev] Let's stop eating exceptions in dict lookupScott Dial scott+python-dev at scottdial.com
Tue May 30 01:48:56 CEST 2006
Raymond Hettinger wrote:
> If it is really 0.5%, then we're fine.  Just remember that PyStone is an 
> amazingly uninformative and crappy benchmark.

Since Armin seems to not like having to justify his patch with any 
performance testing, I wrote a handful of dict insertion exercises and 
could find no real performance impact. In the case of an exception, it 
was much faster, but that is because it is not inserting anything into 
the dictionary.

IOW if it is a bad change in behavior. Previously, the exception was 
swallowed and it was assumed to be a new key despite the exception. This 
is an obscure use case that could creep up it's ugly head.

class K(int):
    def __cmp__(self, o): raise Exception()

d = {}
for i in xrange(10):
     d[K()] = i
for k in d.keys():
     print d[k]

Despite the incomparability, this throws no error in previous versions 
and the dict is still usable for the expected purpose.

-- 
Scott Dial
scott at scottdial.com
scodial at indiana.edu
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4