Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'mathematics': 0.05; 'true,': 0.05; "(i'd": 0.09; 'objects,': 0.09; 'subject:design': 0.09; 'python': 0.11; 'backward': 0.16; 'dict': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inclined': 0.16; 'intersection': 0.16; 'mathematics.': 0.16; "operand's": 0.16; 'semantics': 0.16; 'subject:Language': 0.16; 'value),': 0.16; 'wrote:': 0.18; 'bit': 0.19; '>>>': 0.22; '(or': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'possibility': 0.29; 'sets': 0.30; 'message-id:@mail.gmail.com': 0.30; '13,': 0.31; "d'aprano": 0.31; 'sep': 0.31; 'steven': 0.31; "we're": 0.32; 'fri,': 0.33; 'implemented': 0.33; "i'd": 0.34; 'could': 0.34; 'basic': 0.35; 'beyond': 0.35; 'case,': 0.35; 'equal': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'maintained': 0.36; 'example,': 0.37; 'two': 0.37; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'most': 0.60; 'more': 0.64; 'between': 0.67; 'union': 0.69; 'forced': 0.84; "it'd": 0.84; 'usage.': 0.84; 'demand': 0.91; '2013': 0.98 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:to :content-type; bh=INmEDhMLb6kTHMkUFVW3jzTaBJLmWZxpxKpwWsrl4RA=; b=TqYW/2cBAO+H76l3xLrIHeqXBYkAw4W/c7wKx3pRmFVH4NOPub9O4e3RyseI0elt13 mRXgjvzdoP0v8gJq2qmBzLsAmRB5hZoELS7AY70iZ0OVJo56p/dBWkkHn/WJTpVYCH4k AhiEIVf9u/YZaay8hdyHKAUKm6HjhxbSeyK5SmrzcIXLL8r6PuStW0R0CuDvoxeZYIa1 MlJWGNOak0N1ftM3NRINecuQlsiv0mTk3hds0vAPjcFEDkwSwBKCwPPAe0ljt7MHegm+ XtdXF7wb+SPvwLCfPLPwR8qhlDElL4uW7YQ1Yz2bGwNT3fE2x8JOh33PxQ59hNiE1rxT c6wg== MIME-Version: 1.0 X-Received: by 10.58.67.101 with SMTP id m5mr235454vet.29.1379057967798; Fri, 13 Sep 2013 00:39:27 -0700 (PDT) In-Reply-To: <52329db3$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <522eb795$0$29999$c3e8da3$5496439d@news.astraweb.com> <5230ff66$0$29988$c3e8da3$5496439d@news.astraweb.com> <52315238$0$29999$c3e8da3$5496439d@news.astraweb.com> <52329db3$0$29988$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 13 Sep 2013 17:39:27 +1000 Subject: Re: Language design From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1379057976 news.xs4all.nl 15952 [2001:888:2000:d::a6]:34954 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:54106 On Fri, Sep 13, 2013 at 3:08 PM, Steven D'Aprano wrote: > For example, take intersection of two sets s and t. It is a basic > principle of set intersection that s&t == t&s. Note that, while this is true, the two are not actually identical: >>> set1 = {0,1,2} >>> set2 = {0.0,1.0,3.0} >>> set1&set2 {0.0, 1.0} >>> set2&set1 {0, 1} >>> (set1&set2) == (set2&set1) True I'd actually posit that Python has this particular one backward (I'd be more inclined to keep the left operand's value), but it's completely insignificant to most usage. But in any case, there's already the possibility that a set union can be forced to make a choice between two equal objects, so we're already a bit beyond the purity of mathematics. Python could have implemented dicts much more like "sets with values", with set semantics maintained throughout, but it'd require some oddities: >>> {1:"asdf"} == {1:"asdf"} True >>> {1:"asdf"} == {1:"qwer"} False "Sets with values" semantics would demand that these both be True, which is grossly unintuitive. So while it may be true in pure mathematics that a set is-a dict (or a dict is-a set), it's bound to create at least as many gotchas as it solves. ChrisA