Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!newsfeed.xs4all.nl!newsfeed2a.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; 'argument': 0.05; 'think,': 0.07; 'arguments': 0.09; 'runs': 0.10; 'cc:addr:python-list': 0.11; 'bytecode': 0.16; 'func': 0.16; 'path.': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'skip': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'nearly': 0.26; 'push': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'cases': 0.33; 'could': 0.34; 'case,': 0.35; 'received:google.com': 0.35; 'done': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'two': 0.37; '2015': 0.84 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:to :cc:content-type; bh=s16SyRJ+vNpRbltqxNIz1sz+s99YB+i8Ce59kZO+DY8=; b=FqRSYhayzq+xjCuIBKYq/TuL8sCFljioKZKUZx1Zc40Ncvrg6o0xjvh8ZWD6B9Uk/Y V7FCjv+OYEtG8TpuH2zwXKFrnSEuSwhV4CYrQngXoMWcbg4/oLD5o5zmXdSgi3/714zC zvtfmt83VeQh8mXJy8NBXt5bRaiFO4wtZ3j6ynOw7b3R6C5iQoL1XaHkbIWHybNbX5d1 3/EIqex2oPS5wK+srtGjPGBT9lRNmL25GlE6Z+D1toc8s8XP69SUpjEdPtX52U6IYzvH kuTdCtqX8EOBcpbRS0S2OS2nZflVzASat5z3r4AbsLUslVQPZyn9ChK/MKQUhxD3JwCN mObQ== MIME-Version: 1.0 X-Received: by 10.182.111.231 with SMTP id il7mr8499157obb.15.1431357219176; Mon, 11 May 2015 08:13:39 -0700 (PDT) In-Reply-To: References: <554f2bb6$0$13011$c3e8da3$5496439d@news.astraweb.com> <555028d8$0$12997$c3e8da3$5496439d@news.astraweb.com> <8Y_3x.668959$LI3.568865@fx24.am4> Date: Mon, 11 May 2015 10:13:39 -0500 Subject: Re: Calling a function is faster than not calling it? From: Skip Montanaro To: BartC Cc: Python Content-Type: text/plain; charset=UTF-8 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: , Newsgroups: comp.lang.python Message-ID: Lines: 11 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1431357228 news.xs4all.nl 2907 [2001:888:2000:d::a6]:56674 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 3675 X-Received-Body-CRC: 3727037533 Xref: csiph.com comp.lang.python:90393 On Mon, May 11, 2015 at 10:01 AM, BartC wrote: > (1) It has an extra argument ('code'), in addition to any normal arguments > of func (0 in this case) Which might well push execution down the unoptimized code path. Also, ISTR that Steven's original timeit runs tacked on a standalone "eval ; ..." to the function call case, so the LOAD_GLOBAL bytecode would have been done in the function call case as well. He was, I think, doing what he could to make the two cases as nearly identical as he could. Skip