Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?) Date: Thu, 26 Nov 2015 18:14:02 +1100 Lines: 22 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=UTF-8 X-Trace: news.uni-berlin.de 7TTg5GeJEBdcCxXd3g5PYA8hNM2LXH7P/fu97HgEy7bw== 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; 'received:209.85.223': 0.03; 'key.': 0.07; 'keys,': 0.07; 'cc:addr:python-list': 0.09; 'dict': 0.09; 'insertion': 0.09; 'likewise': 0.09; 'mutable': 0.09; 'prevents': 0.09; 'python.': 0.11; 'subject: \n ': 0.15; 'thu,': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; "key's": 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'retrieval,': 0.16; 'subject:?)': 0.16; 'wrote:': 0.16; 'looked': 0.16; 'basically': 0.18; 'changes': 0.20; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'keys': 0.22; 'tuples': 0.22; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'dictionary': 0.29; 'hash': 0.29; 'sure,': 0.29; 'objects': 0.29; "d'aprano": 0.33; 'steven': 0.33; 'equal': 0.34; 'received:google.com': 0.35; 'nov': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'no,': 0.38; 'received:209': 0.38; 'means': 0.39; 'subject:-': 0.39; 'making': 0.62; 'different': 0.63; 'between': 0.65; 'manner': 0.69; '26,': 0.72; 'chrisa': 0.84; 'to:none': 0.91 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:cc :content-type; bh=cq3sXsqnAIxqFf8UM/Dpxn6x2/ubVlHpg/I1TVUmM1A=; b=sCGMI97sfbcWv5+d5WMTQX5iJHOIuCUxTUv76kOe1tUk8I4PqLUlHwyx40SjyM/5rz 7d1RU6hvmljbgmzMemlO68/9XLUjvgLZgj5ms8p4v+RmrTuFoUCO+8jxtR6m4Dt6kHep WkeM59wBi4zohEkHaRbMUoYRk5TknEiG+FIepGSokxmkRj2xt41L6jDdLvb8VueVz1a4 g4K5H1u/UldfKjMKhtTMCd9/8RhSayRXi1CC8TPt5Rl4qpa+SGXkK75DpbiaRyhz5Fa3 b3wrjjXNznkOCXyfbvQH3KQUaFk4goLtbEyfy7InbqYE0IcEO+wCeXRSYDm5ITuTD0Zm YLPQ== X-Received: by 10.107.10.233 with SMTP id 102mr38503826iok.31.1448522042770; Wed, 25 Nov 2015 23:14:02 -0800 (PST) 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:99536 On Thu, Nov 26, 2015 at 5:52 PM, 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. > > Nothing prevents using mutable objects as keys in Python. > > Sure, you _can_. But if the key's hash changes between dict insertion and retrieval, all manner of invariants will break, and likewise if two equal objects have different hashes. From which you can deduce logically that any object used as a key must remain (not) equal to everything that it was (not) equal to from that time until it is looked up... which basically means its value mustn't change. It must be immutable. ChrisA