Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.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.042 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'subject:not': 0.03; 'variables': 0.07; 'dict': 0.16; 'reminded': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'stack': 0.19; '(the': 0.22; 'mention': 0.26; 'second': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'skip:p 30': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'actual': 0.34; 'received:google.com': 0.35; 'there': 0.35; 'object,': 0.36; 'subject:?': 0.36; 'turn': 0.37; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'first': 0.61; '"fast"': 0.84; '2015': 0.84; 'otten': 0.84 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=G9ohpTW9niaYJk3cy1mdjPz4H/tdxkuN3W4/Bn5fI1k=; b=IqzK1qQG/vH/xbdhEoV8Mjl/rqMwsSFRM1IP4FtzBBXL16eJKurdqopmhNKdhRvgIo 4uWPcgGah3rweUC6kIhj+k5BE40bXvK8IX3+krBcIHkaKlCITysLls8/OrNKfsAnnCJ2 Jh4S898Yxxqz13+tZ5AyufWUNvL2k49G8Ia2Lx/L0AgagX0XCMyRVhqhYsaMKcF3MGFg VS2P+gMVmjLbhQmlXvTht1gMJelcODzRZgYt6T2WjjOxry6bvAqEKA1DzxO3SU4KXNSD 48eqFRoKZ2VMwrgIp8JdOFOVWqsmbnB9uTKzMp95uehA8/rH0EDH1u/Dupg3Ja/iKetM 2UUw== X-Received: by 10.50.225.35 with SMTP id rh3mr9729882igc.29.1431275164857; Sun, 10 May 2015 09:26:04 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <554f2bb6$0$13011$c3e8da3$5496439d@news.astraweb.com> <554f700f$0$13011$c3e8da3$5496439d@news.astraweb.com> From: Ian Kelly Date: Sun, 10 May 2015 10:25:24 -0600 Subject: Re: Calling a function is faster than not calling it? To: 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1431275173 news.xs4all.nl 2970 [2001:888:2000:d::a6]:48486 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90294 On Sun, May 10, 2015 at 10:14 AM, Peter Otten <__peter__@web.de> wrote: > When there was an actual speed-up I also had a look at > PyEval_GetGlobals/Locals() which in turn call > > PyEval_GetFrame() > > and > > PyEvalPyFrame_FastToLocalsWithError() > > whatever these do. (The first function reminded me of sys._getframe() hence > the mention of stack inspection) Based on the names, I surmise that the first one gets the top stack frame object, and that the second one extracts the "fast" local variables from the frame object and builds a dict of them for use by eval.