Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'python': 0.11; 'def': 0.12; "'%s(%r)'": 0.16; '23,': 0.16; 'be:': 0.16; 'collections': 0.16; 'does,': 0.16; 'ignoring': 0.16; 'inheritance': 0.16; 'list):': 0.16; 'ordereddict': 0.16; 'remembers': 0.16; 'simplicity,': 0.16; 'subject:object': 0.16; 'elements': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'library': 0.18; 'basically': 0.19; 'code,': 0.22; 'example': 0.22; 'import': 0.22; 'previously': 0.22; 'least': 0.26; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'cool': 0.30; 'raymond': 0.30; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; '(which': 0.31; '3.2': 0.31; 'changed.': 0.31; "d'aprano": 0.31; 'noted': 0.31; 'overhead': 0.31; 'steven': 0.31; 'class': 0.32; 'skip:_ 10': 0.34; 'subject:the': 0.34; 'advice': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'level': 0.37; 'skip:o 20': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'release': 0.40; 'how': 0.40; 'first': 0.61; 'save': 0.62; 'show': 0.63; 'kind': 0.63; 'saw': 0.77; 'article,': 0.84; 'pardon': 0.84; 'inheritance,': 0.93; '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:from:date:message-id:subject:to :content-type; bh=XUXfcRXsxHMSS7Pq8XetyM2XqQ1vmAhePdA8DIGWWTs=; b=EjH+E8suhq8novabc9u7+JChHb+XgnWbRWdMXT+iXsMHEKwMzJBiYyimBYaQxKp9pV DLSjY6AIPrhMrbWGDeMxdTvoD9XlzglCi56r1M/3vpmLCPsKK1Xy4PkAXsJIILetrM3U 4EhLJna3tkCW9JpKVUTdeosZNhUffO6yARBcceHldMf+fiEQbfMZhizar4sm32N+ChXT FQ2A3eO7HbdLiRE4Yzi1+882k+uYy8+1da6qNX4KIIgbK95Deb5nxlV7wFkSVPjHSsHF elsyX51QJW5LHGKq1jfqSdGlKGh7zWm4hLdi/TqQzbvDbWMpYo16Yb3UsnyP3ZQHemnM qAog== X-Received: by 10.68.180.101 with SMTP id dn5mr20956pbc.209.1372182328974; Tue, 25 Jun 2013 10:45:28 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <51C74D6E.6030200@rece.vub.ac.be> References: <15ba0011-bbf1-42f7-b3ea-1c1d4b70e56b@googlegroups.com> <51c66962$0$29999$c3e8da3$5496439d@news.astraweb.com> <20130623133546.GA2308@capricorn> <51c723b4$0$29999$c3e8da3$5496439d@news.astraweb.com> <51C74D6E.6030200@rece.vub.ac.be> From: Ian Kelly Date: Tue, 25 Jun 2013 11:44:48 -0600 Subject: Re: What is the semantics meaning of 'object'? To: Python 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1372182747 news.xs4all.nl 15868 [2001:888:2000:d::a6]:49935 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49175 On Sun, Jun 23, 2013 at 1:33 PM, Antoon Pardon wrote: > Op 23-06-13 18:35, Steven D'Aprano schreef: >> Please don't. This is false economy. The time you save will be trivial, >> the overhead of inheritance is not going to be the bottleneck in your >> code, and by ignoring super, you only accomplish one thing: >> >> - if you use your class in multiple inheritance, it will be buggy. > > > Which is why I don't understand that the python standard library still > contains that kind of code. At least it did in 3.2 and I saw nothing > in the 3.3 release notes that would make me suspect this has changed. This bothers me as well. If you look at Raymond Hettinger's "super() considered super" article, he includes the (correct) advice that super() needs to be used at every level of the call chain. At the end of the article, he offers this example to show how "easy" multiple inheritance can be: from collections import Counter, OrderedDict class OrderedCounter(Counter, OrderedDict): 'Counter that remembers the order elements are first seen' def __repr__(self): return '%s(%r)' % (self.__class__.__name__, OrderedDict(self)) def __reduce__(self): return self.__class__, (OrderedDict(self),) oc = OrderedCounter('abracadabra') Which is pretty cool in its simplicity, but here's the rub (which I have previously noted on this list): OrderedDict doesn't use super. Counter does, but not cooperatively; it just calls super().__init__() with no arguments. So the fact that this example works at all is basically luck.