Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6502 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2011-05-29 10:32 +1000 |
| Last post | 2011-05-29 08:51 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: float("nan") in set or as key Chris Angelico <rosuav@gmail.com> - 2011-05-29 10:32 +1000
Re: float("nan") in set or as key Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-29 08:51 +0000
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-05-29 10:32 +1000 |
| Subject | Re: float("nan") in set or as key |
| Message-ID | <mailman.2209.1306629167.9059.python-list@python.org> |
On Sun, May 29, 2011 at 10:28 AM, Albert Hopkins <marduk@letterboxes.org> wrote: > This is the same nan, so it is equal to itself. > Actually, they're not. But it's possible the dictionary uses an 'is' check to save computation, and if one thing 'is' another, it is assumed to equal it. That's true of most well-behaved objects, but nan is not well-behaved :) Chris Angelico
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2011-05-29 08:51 +0000 |
| Message-ID | <4de20915$0$29996$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #6502 |
On Sun, 29 May 2011 10:32:43 +1000, Chris Angelico wrote: > On Sun, May 29, 2011 at 10:28 AM, Albert Hopkins > <marduk@letterboxes.org> wrote: >> This is the same nan, so it is equal to itself. >> >> > Actually, they're not. But it's possible the dictionary uses an 'is' > check to save computation, and if one thing 'is' another, it is assumed > to equal it. That's true of most well-behaved objects, but nan is not > well-behaved :) *Exactly* correct. NAN != NAN even if they are the same NAN, by design. This makes NANs ill- behaved, but usefully so. Most (all?) Python built-ins assume that any object X is equal to itself, so they behave strangely with NANs. -- Steven
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web