Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.087 X-Spam-Evidence: '*H*': 0.83; '*S*': 0.01; 'operator,': 0.09; 'cc:addr :python-list': 0.11; 'elem': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'instance:': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'question': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; 'argue': 0.31; 'assert': 0.31; 'though.': 0.31; 'fri,': 0.33; 'subject: (': 0.35; 'no,': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'subject:?': 0.36; 'should': 0.36; 'mar': 0.68; 'obvious': 0.74; '10:11': 0.84; '2015': 0.84; 'safe.': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=FdiOBxwCihluCh4Hbof7VqFY60cCOhSFjLIRbOQOZss=; b=xHxu/58PJTM1T9BGDN1kkpwj/x5Nw55X75+tdLRpCMN24qOrbXhwnR88wrlPH0HtZn pG8lRQj3bcPVN9XlzxzMtRBxSdeWgOF7KGlIvwZN3YL/xjmIhwQdwsSjhV7OqhNSmBi4 jBkG/pjGhxgq0PrOuFfr3F5WXntSA5+qlHnNWD4AFLEWoswDhoLYVZMskS+DjE2yGQEl CkTrXmtCsUZBjKb5boTmYT1BslL2LL5EXdgT70IHiGXs2vj2quHG5rh0iw26YA+C1WiP 5mN2d+4KetFC0lY8WzHh4QsIETRrRvyKCl9vVPnE9po05Te7h+6FyoQpOFanlnrbzaUp gx/A== MIME-Version: 1.0 X-Received: by 10.50.131.196 with SMTP id oo4mr24272190igb.2.1425597905390; Thu, 05 Mar 2015 15:25:05 -0800 (PST) In-Reply-To: References: Date: Fri, 6 Mar 2015 10:25:05 +1100 Subject: Re: Is nan in (nan,) correct? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1425597914 news.xs4all.nl 2947 [2001:888:2000:d::a6]:55400 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:86965 On Fri, Mar 6, 2015 at 10:11 AM, wrote: > I would argue that if `a is b` then it is obvious that `a == b` This is not true for float("nan"), though. The question is, is your above statement a valid optimization for the 'in' operator, or not? And no, it isn't, because it's not perfectly safe. However, there are other invariants that mean that 'in' has to allow object identity to count; for instance: for elem in collection: assert elem in collection should never assert-fail. ChrisA