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 abarry
Recipients Hamish Campbell, abarry, docs@python
Date 2016-01-06.03:40:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Set displays appear to be the culprit here:

>>> class A:
...   count = 0
...   def __init__(self):
...     self.cnt = self.count
...     type(self).count += 1
...   def __eq__(self, other):
...     return type(self) is type(other)
...   def __hash__(self):
...     return id(type(self))
>>> e={A(), A(), A(), A(), A()}
>>> e
{<__main__.A object at 0x002BB2B0>}
>>> list(e)[0].cnt
>>> list(e)[0].count
>>> A.count = 0
>>> q=set([A(), A(), A(), A(), A()])
>>> q
{<__main__.A object at 0x002BB310>}
>>> list(q)[0].cnt
>>> list(q)[0].count

I'm guessing this is an optimization and/or set displays just don't keep ordering at definition time.

Do you have a use case where `x == y`/`hash(x) == hash(y)` does not mean that `x` and `y` should be interchangeable? True and 1 are 100% interchangeable, minus their str() output, and my example is very unlikely to ever appear in actual code.

Probably just better to fix the docs to specify that sets literals don't check ordering.
Date User Action Args
2016-01-06 03:40:53abarrysetrecipients: + abarry, docs@python, Hamish Campbell
2016-01-06 03:40:53abarrysetmessageid: <>
2016-01-06 03:40:53abarrylinkissue26020 messages
2016-01-06 03:40:52abarrycreate