Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!newsswitch.lcs.mit.edu!grapevine.lcs.mit.edu!not-for-mail From: Alan Bawden Newsgroups: comp.lang.python Subject: Re: Proposal: === and !=== operators Date: Sat, 12 Jul 2014 01:07:28 -0400 Organization: MIT Computer Science & Artificial Intelligence Lab Lines: 38 Message-ID: References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53c0abe8$0$9505$c3e8da3$5496439d@news.astraweb.com> NNTP-Posting-Host: scooby-doo.csail.mit.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: grapevine.csail.mit.edu 1405141648 92882 128.30.2.141 (12 Jul 2014 05:07:28 GMT) X-Complaints-To: security@csail.mit.edu NNTP-Posting-Date: Sat, 12 Jul 2014 05:07:28 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Cancel-Lock: sha1:g6kaN1BAG6RgdxnsM+c+J8Oimx4= Xref: csiph.com comp.lang.python:74366 Steven D'Aprano writes: > But perhaps we only care about changes in value, not type. NAN or no NAN, > list equality works fine: > > py> data = [1.0, 2.0, float('nan'), 4.0] > py> old = data[:] > py> old == data # No changes made yet, should return True > True You lost me right here. If list equality is determined by comparing lists element-by-element, and the second element of old is _not_ equal to the second element of data, then why should old and data be equal? In fact, I find myself puzzled about exactly how list equality is actually defined. Consider: >>> a = float('nan') >>> x = [1, a, 9] >>> y = [1, a, 9.0] >>> x == y True So is there some equality predicate where corresponding elements of x and y are equal? >>> map(operator.eq, x, y) [True, False, True] It's not "==". >>> map(operator.is_, x, y) [True, True, False] And it's not "is". -- Alan Bawden