Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-1.proxad.net!198.186.194.247.MISMATCH!news-out.readnews.com!transit3.readnews.com!panix!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: float("nan") in set or as key Date: Sun, 29 May 2011 14:41:13 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 29 Message-ID: References: <4DE1881C.8000701@mrabarnett.plus.com> NNTP-Posting-Host: 67-220-17-92.usiwireless.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: reader1.panix.com 1306680073 27267 67.220.17.92 (29 May 2011 14:41:13 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Sun, 29 May 2011 14:41:13 +0000 (UTC) User-Agent: slrn/0.9.9p1 (Linux) Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6543 On 2011-05-29, Wolfgang Rohdewald wrote: > On Sonntag 29 Mai 2011, Tim Delaney wrote: >> There's a second part the mystery - sets and dictionaries (and >> I think lists) assume that identify implies equality (hence >> the second result). This was recently discussed on >> python-dev, and the decision was to leave things as-is. > > On Sonntag 29 Mai 2011, Grant Edwards wrote: >> Even if they are the same nan, it's still not equal to itself. > > if I understand this thread correctly, they are not equal to itself > as specified by IEEE And Python follows that convention. > but Python treats them equal in sets and dictionaries for performance > reasons It treats them as identical (not sure if that's the right word). The implementation is checking for ( A is B or A == B ). Presumably, the assumpting being that all objects are equal to themselves. That assumption is not true for NaN objects, so the buggy behavior is observed. -- Grant