Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'sure.': 0.05; 'cached': 0.07; 'used.': 0.07; 'python': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'rewritten': 0.09; 'though)': 0.09; 'am,': 0.13; 'wrote:': 0.15; 'executed.': 0.16; 'lookups': 0.16; 'optimizing': 0.16; 'subject:Early': 0.16; 'cc:addr:python-list': 0.16; 'pm,': 0.16; 'aug': 0.19; 'cc:2**0': 0.21; 'cc:no real name:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'tue,': 0.23; 'code': 0.24; 'tried': 0.27; 'sort': 0.28; 'compile': 0.29; 'code,': 0.29; 'cc:addr:python.org': 0.30; 'binding': 0.30; 'loads': 0.30; 'chris': 0.32; 'message-id:@gmail.com': 0.32; 'rather': 0.33; 'to:addr:python-list': 0.34; 'header:X-Complaints- To:1': 0.34; 'header:User-Agent:1': 0.34; 'probably': 0.35; 'certain': 0.36; 'some': 0.37; 'but': 0.37; 'could': 0.37; 'received:org': 0.38; 'subject:: ': 0.38; 'two': 0.38; 'case': 0.39; 'should': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'might': 0.39; 'where': 0.40; 'increase': 0.64; 'minutes': 0.67; 'sfxlen:4': 0.67; 'hand,': 0.76; 'pfxlen:big': 0.77; 'interesting,': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Gelonida N Subject: Re: Early binding as an option Date: Wed, 03 Aug 2011 00:54:11 +0200 References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: python-list@python.org X-Gmane-NNTP-Posting-Host: unicorn.dungeon.de User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Lightning/1.0b2 "" In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1312325667 news.xs4all.nl 23953 [2001:888:2000:d::a6]:49736 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10771 On 08/03/2011 12:26 AM, Chris Angelico wrote: > On Tue, Aug 2, 2011 at 11:21 PM, Gelonida N wrote: >> On the other hand: It might be interesting, that the early binding would >> just take place when python is invoked with -O >> > > This could be an excellent safety catch, but on the other hand, it > might destroy all value of the feature - once again, it would be > optimizing in the sole case where the code is probably better > rewritten in C. > > Or would this be a sort of "half-way house" - this is where we need > more performance, let's spend two minutes tweaking it in Python rather > than dropping to C - to get some of the performance gains? Not really sure. I would guess, that really tight inner loops should be rewritten with Cython (never tried it though) or in C if performance is really that critical. On the other hand it could be nice to get a certain performance increase with some pragmas without rendering the code completely unreadable. I have loads of places in my code, where name lookups were required only at compile time or at the first time when code is executed. For every consecutive call a cached object-reference could be used.