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 Dennis Sweeney
Recipients Dennis Sweeney, rhettinger, serhiy.storchaka
Date 2020-06-08.22:48:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1591656512.01.0.515498863518.issue40889@roundup.psfhosted.org>
In-reply-to
Content
A demo:

>>> class Int(int):
...     hash_calls = 0
...     def __hash__(self):
...         Int.hash_calls += 1
...         return super().__hash__()
...
>>> left = {Int(1): -1, Int(2): -2, Int(3): -3, Int(4): -4, Int(5): -5, Int(6): -6, Int(7): -7}
>>> right = {Int(1): -1, Int(2): -2, Int(3): -3, Int(4): -4, Int(5): -5, Int(8): -8, Int(9): -9}
>>> Int.hash_calls = 0
>>> left.items() ^ right.items()
{(9, -9), (7, -7), (8, -8), (6, -6)}
>>> Int.hash_calls
<Result: 14 on Master, but only 4 on PR 20718>


It looks like the same trick (searching by key and comparing values before maybe constructing a 2-tuple) might give similar performance improvements for dict_items.__or__, dict_items.__and__, and dict_items.__sub__. Is it worth discussing these other operators in this issue?
History
Date User Action Args
2020-06-08 22:48:32Dennis Sweeneysetrecipients: + Dennis Sweeney, rhettinger, serhiy.storchaka
2020-06-08 22:48:32Dennis Sweeneysetmessageid: <1591656512.01.0.515498863518.issue40889@roundup.psfhosted.org>
2020-06-08 22:48:32Dennis Sweeneylinkissue40889 messages
2020-06-08 22:48:31Dennis Sweeneycreate