Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Mark Lawrence Newsgroups: comp.lang.python Subject: Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Date: Thu, 26 Nov 2015 11:17:56 +0000 Lines: 34 Message-ID: References: <87d1v5emhl.fsf@elektro.pacujo.net> <564e6a62$0$1620$c3e8da3$5496439d@news.astraweb.com> <56556DF8.1080407@rece.vub.ac.be> <878u5mns8z.fsf@elektro.pacujo.net> <874mganq2q.fsf@elektro.pacujo.net> <56565822$0$1617$c3e8da3$5496439d@news.astraweb.com> <87oaeh2qy0.fsf@elektro.pacujo.net> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de ng1Lj+KI9fc64lacdphS0wvrnWzBou0DKWhaFAh1j0XQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.05; 'key.': 0.07; 'keys,': 0.07; 'lookup': 0.09; 'mutable': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'satisfy': 0.09; 'python': 0.10; 'subject: \n ': 0.15; 'correctly,': 0.16; 'correctness': 0.16; 'i1,': 0.16; 'i2,': 0.16; 'keys"': 0.16; 'received:194.126': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:?)': 0.16; 'wrote:': 0.16; 'language': 0.19; 'algorithm': 0.20; "aren't": 0.22; 'keys': 0.22; 'lawrence': 0.22; 'tuples': 0.22; 'header:In-Reply-To:1': 0.24; 'discussion': 0.24; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; '(e.g.': 0.27; 'url:moin': 0.27; 'function': 0.28; 'values': 0.28; 'comparison': 0.29; 'dictionary': 0.29; 'equality': 0.29; 'equivalent,': 0.29; 'hash': 0.29; 'key,': 0.29; 'usable': 0.29; 'objects': 0.29; 'url:wiki': 0.30; '"the': 0.32; 'language.': 0.32; 'url:python': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'should': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'received:org': 0.37; 'no,': 0.38; 'why': 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'mark': 0.40; 'received:194': 0.61; 'charset:windows-1252': 0.62; 'making': 0.62; 'engines': 0.63; 'different': 0.63; 'our': 0.64; 'pythonistas,': 0.84 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 107.93.126.194.pool.dsl.daisyplc.net X-Mozilla-News-Host: news://news.gmane.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: <87oaeh2qy0.fsf@elektro.pacujo.net> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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:99556 On 26/11/2015 06:52, Marko Rauhamaa wrote: > Steven D'Aprano : > >> Making tuples mutable would break their use as dictionary keys, which is a >> *critical* use. > > No, it wouldn't. Any object that provides __hash__() and __eq__() can be > used as a key. > Almost, see https://wiki.python.org/moin/DictionaryKeys. Under the title "Types Usable as Dictionary Keys" it states "The discussion above should explain why Python requires that: To be used as a dictionary key, an object must support the hash function (e.g. through __hash__), equality comparison (e.g. through __eq__ or __cmp__), and must satisfy the correctness condition above." The correctness condition is:- "For such a lookup algorithm to work correctly, the hash functions provided must guarantee that if two keys produce different hash values then the two key objects are not equivalent, that is, for all i1, i2, if hash(i1) != hash(i2), then i1 != i2" Aren't search engines just wonderful :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence