Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Antoon Pardon Newsgroups: comp.lang.python Subject: Re: Suggestion: make sequence and map interfaces more similar Date: Wed, 30 Mar 2016 10:55:46 +0200 Lines: 33 Message-ID: References: <56f8836b$0$1602$c3e8da3$5496439d@news.astraweb.com> <56FA8C71.4050306@rece.vub.ac.be> <56fb677f$0$11121$c3e8da3@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de EEPtLlXdz1Z8WathtzRhMgbFPttw1PbX2mQe/FX8ZboQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'true,': 0.04; 'received:134': 0.05; 'key.': 0.07; 'stable.': 0.09; 'argument': 0.15; '(and,': 0.16; '*do': 0.16; '*other*': 0.16; 'keys.': 0.16; 'mapping,': 0.16; 'mappings.': 0.16; 'pairs': 0.16; 'received:ac.be': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'spotted': 0.16; 'subject:interfaces': 0.16; 'subject:make': 0.16; "shouldn't": 0.18; 'keys': 0.22; 'header:In-Reply-To:1': 0.24; 'discussion': 0.24; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'point.': 0.27; 'correct': 0.28; 'values': 0.28; 'directly,': 0.29; 'key,': 0.29; 'necessary,': 0.29; 'value)': 0.29; "we're": 0.30; 'received:be': 0.30; 'operations': 0.31; 'generally': 0.32; 'changed': 0.33; 'steven': 0.33; "i'll": 0.33; 'changing': 0.34; 'gives': 0.35; 'done': 0.35; 'mapping': 0.35; 'stable': 0.35; 'but': 0.36; 'there': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'being': 0.37; 'expect': 0.37; 'associated': 0.38; 'mean': 0.38; 'means': 0.39; 'sure': 0.39; 'application': 0.39; 'to:addr:python.org': 0.40; 'relationship': 0.61; 'subject:more': 0.61; 'more': 0.63; 'between': 0.65; 'limit': 0.65; 'obvious': 0.76; 'anywhere.': 0.84; "d'aprano:": 0.84; 'pardon': 0.84; 'schreef': 0.84 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.6.0 In-Reply-To: <56fb677f$0$11121$c3e8da3@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:106037 Op 30-03-16 om 07:43 schreef Steven D'Aprano: > Yes, we're all very impressed that you spotted the trivial and obvious > loophole that changing a key:value will change the key:value that you just > changed *wink* but that doesn't really move the discussion anywhere. > > This is not an argument about dicts being mutable, because clearly they > aren't. This is an argument about key:value pairs being stable. "Stable" > doesn't mean "immutable". If you change the value associated with a key > directly, then it will change. That's the whole point. But if you change > *one* key, the relationship between *other* keys and their values shouldn't > change. > > Given a surjection (many-to-one mapping) between keys and values in a > mapping, we expect that changing the mapping of one key will not affect > other keys. To be pedantic, by "change" I mean deleting the key (and, if > necessary, value) or reassigning a new value to the key. To be even more > pedantic, mutations to the value *do not count*. I don't expect that generally. Sure there are specific mapping implementations for which this is true, but I see no reason to limit the word mapping only to those kind of data-types. What I want from a mapping is that it gives me the correct correspondence between a key and a value for the application I am using it for. If that means a "stable" mapping I'll limit the operations on that mapping as to keep it that way. Which in a number of case can be perfectly done with python-lists. So generally there is no reason to limit the word "mapping" to stable mappings. -- Antoon Pardon