Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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; 'subject:code': 0.07; 'versions.': 0.07; 'python': 0.09; 'difference,': 0.09; 'terry': 0.09; 'bug': 0.10; '2.7': 0.13; 'dec': 0.15; '*why*': 0.16; '>>on': 0.16; '>on': 0.16; '>the': 0.16; 'afaik.': 0.16; 'bug,': 0.16; 'head,': 0.16; 'reedy': 0.16; 'skip:> 20': 0.16; 'subject:dead': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'pointed': 0.17; 'specify': 0.17; '>>>': 0.18; 'issue.': 0.20; 'tracker': 0.20; 'mention': 0.23; 'url:bugs': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'forgot': 0.27; 'skip:> 10': 0.27; '-0700,': 0.29; "d'aprano": 0.29; 'steven': 0.29; "i'm": 0.29; 'keyword': 0.30; 'version,': 0.30; 'url:python': 0.32; 'could': 0.32; 'certain': 0.33; 'to:addr :python-list': 0.33; 'confirmed': 0.35; 'open': 0.35; 'pm,': 0.35; 'subject:?': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'url:org': 0.36; "didn't": 0.36; 'test': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'think': 0.40; 'days': 0.60; 'content- disposition:inline': 0.60; 'between': 0.63; 'here': 0.65; 'believe': 0.69; '3.4': 0.84; 'glad': 0.86 Date: Wed, 5 Dec 2012 21:50:58 +0100 From: Bruno Dupuis To: python-list@python.org Subject: Re: why does dead code costs time? References: <50bf85c0$0$29994$c3e8da3$5496439d@news.astraweb.com> <20121205182413.GI10865@hud> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1354740657 news.xs4all.nl 6848 [2001:888:2000:d::a6]:55933 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34324 On Wed, Dec 05, 2012 at 03:41:19PM -0500, Terry Reedy wrote: > On 12/5/2012 1:24 PM, Bruno Dupuis wrote: > >On Wed, Dec 05, 2012 at 10:59:26AM -0700, Ian Kelly wrote: > >>On Wed, Dec 5, 2012 at 10:34 AM, Steven D'Aprano > >> wrote: > >>>The difference is almost certain between the LOAD_CONST and the > >>>LOAD_GLOBAL. > >>> > >>>As to *why* there is such a difference, I believe that's a leftover from > >>>early Python days when None was not a keyword and could be reassigned. > >> > >>I think this should even be considered a bug, not just a missing > >>optimization. Consider: > > > >This is definitely a bug > > > >>>>>globals()['None'] = 42 > >>>>>def f(x): > >>... return None > >>... print(x) > >>... > >>>>>f('test') > >>42 > > > >This one is pretty scary > > > >The difference between `return None` and `return` leads to inconsistency and > >is in contradiction with the specs, AFAIK. I'm glad we pointed this out. > > You did not specify version, but I confirmed in 3.3.0. Please open a > tracker issue. It is also in 2.7 and 3.4 head, I didn't test other versions. I forgot to mention here the issue I have just opened: http://bugs.python.org/issue16619 -- Bruno Dupuis