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 -- https://mail.python.org/mailman/listinfo/python-list