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 ncoghlan
Recipients Devin Jeanpierre, docs@python, eli.bendersky, georg.brandl, mark.dickinson, ncoghlan, rhettinger, terry.reedy
Date 2011-01-15.23:52:47
SpamBayes Score 4.3688484e-08
Marked as misclassified No
Message-id <1295135569.26.0.0616941834765.issue10912@psf.upfronthosting.co.za>
In-reply-to
Content
Indeed. I was actually wondering if it would be worth trying to write up a section for the language reference to describe the cases where a Python implementation is *expected* to assume reflexive equality. We (IMO) have a problem at the moment due to situations like:

>>> class PyContains(list):
...   def __contains__(self, obj):
...     return any(x==obj for x in self)
... 
>>> nan = float("nan")
>>> nan in [nan]
True
>>> nan in PyContains([nan])
False

This is a bug in the __contains__ definition (it should use "x is obj or x == obj" rather than just the latter expression) but there isn't anything in the language reference to point that out.

Assuming reflexive equality in some places and not in others based on the underlying implementation language is going to be a source of subtle bugs relating to types like float and decimal.Decimal.
History
Date User Action Args
2011-01-15 23:52:49ncoghlansetrecipients: + ncoghlan, georg.brandl, rhettinger, terry.reedy, mark.dickinson, Devin Jeanpierre, eli.bendersky, docs@python
2011-01-15 23:52:49ncoghlansetmessageid: <1295135569.26.0.0616941834765.issue10912@psf.upfronthosting.co.za>
2011-01-15 23:52:47ncoghlanlinkissue10912 messages
2011-01-15 23:52:47ncoghlancreate