Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:: [': 0.04; 'subject:Python': 0.06; 'consistency': 0.09; 'logic': 0.09; 'subject:method': 0.09; 'subject:set': 0.09; 'that).': 0.09; 'mostly': 0.14; 'fabio': 0.16; 'magic': 0.16; 'subject:Dev': 0.16; 'url:pocoo': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'bit': 0.19; 'trying': 0.19; 'subject:] ': 0.20; 'seems': 0.21; '(the': 0.22; 'simpler': 0.24; 'tend': 0.24; 'post': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'related': 0.29; 'is?': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'comments': 0.31; 'invoke': 0.31; 'themselves': 0.32; 'skip:_ 10': 0.34; 'maybe': 0.34; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'curious': 0.36; 'done': 0.36; 'url:org': 0.36; 'changing': 0.37; 'so,': 0.37; 'performance': 0.37; 'nov': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; '12,': 0.39; 'though,': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'future': 0.60; 'up,': 0.60; 'break': 0.61; 'skip:t 30': 0.61; 'worth': 0.66; 'python- dev': 0.84; 'url:2014': 0.84; 'reasons,': 0.91; 'url:16': 0.93 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=euip6a/ojPKUqL2xi7wlDmywx4AjBxYgz8aMssQDalk=; b=oCB+5tArvEZCkHyssdpXX+2UaZicilOzqogHGkmza1l7DPCNtIK2YjSJ/GU0jSTYut p/OsJispBFiVTEn3UaMdIM1A/3Ds6ybi2/QD2kZJ14C1ejM48wTHJmzsX2VuoS3hB8Zx 3mwySY9Mgm33wnzVsWtDFT1uppb5+PGUS2nTRhkXU2nuWtg1tbeQP3TrU76EtgHZ6MfQ ye8hsQrOSNojOUOjBzGT59wPWOzVAUlBAAqjkQ7/UCZxuU0t/2kQNCP2c0RYqINsAJE1 f2o6gWzPRmM2MtqAXsptzX6HqCvoWi9Vfou4lwvi74mX7PzfThrOo4F+81RzAVFWIxdS ZoPA== X-Received: by 10.66.252.193 with SMTP id zu1mr3799959pac.153.1415818774128; Wed, 12 Nov 2014 10:59:34 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <545919B6.7040007@stoneleaf.us> <87a943qyvn.fsf@handshake.de> <545CC204.2010301@stoneleaf.us> <8761eq424e.fsf@handshake.de> From: Ian Kelly Date: Wed, 12 Nov 2014 11:58:53 -0700 Subject: Re: [Python-Dev] Dinamically set __call__ method To: Python Content-Type: text/plain; charset=UTF-8 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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415818783 news.xs4all.nl 2967 [2001:888:2000:d::a6]:39700 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80620 On Wed, Nov 12, 2014 at 8:33 AM, Fabio Zadrozny wrote: > As a reference, I recently found a blog post related to that: > http://lucumr.pocoo.org/2014/8/16/the-python-i-would-like-to-see/ (the Slots > part comments on that). > > It does seem a bit counter-intuitive that this happens the way it does > though, so, can someone from python-dev give some background of why that's > the way it is? i.e.: instead of the approach which would seem simpler which > would do getattr(a, '__call__') instead of > type(a).__dict__['__call__'].__get__(a, type(a)) -- it seems to me it's > mostly because of historical reasons, but I'm really curious why is it so > (and if maybe it's something which python-dev would consider worth changing > in the future -- not sure how much could break because of that though). I'm not "someone from python-dev", but I think it's done to keep the look-up logic predictable and avoid having to call __getattribute__ and __getattr__ when looking up magic methods. For at least __getattribute__ and __getattr__ themselves we *can't* invoke those methods while trying to look them up, so there's a case to be made for consistency in that this way we don't have to remember which magic methods use __getattribute__ and which ones don't. Performance is also part of it, since these methods tend to be invoked frequently.