This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author alex
Recipients Arfrever, alex, josh.r, pitrou, rhettinger, serhiy.storchaka, terry.reedy
Date 2014-04-04.20:31:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1396643479.2.0.911075269516.issue21101@psf.upfronthosting.co.za>
In-reply-to
Content
d[key] += 1 still does two dict lookups, and invokes the hash function twice:

>>> class X(object):
...   def __hash__(self):
...     print "hashed"
...     return 0
...   def __eq__(self, other):
...     return True
...
>>> d = {X(): 0}
hashed
>>> d[X()]
hashed
0
>>> d[X()] = 3
hashed
>>> d[X()] += 1
hashed
hashed
History
Date User Action Args
2014-04-04 20:31:19alexsetrecipients: + alex, rhettinger, terry.reedy, pitrou, Arfrever, serhiy.storchaka, josh.r
2014-04-04 20:31:19alexsetmessageid: <1396643479.2.0.911075269516.issue21101@psf.upfronthosting.co.za>
2014-04-04 20:31:19alexlinkissue21101 messages
2014-04-04 20:31:19alexcreate