Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'cpython': 0.05; 'insert': 0.05; 'url:bitbucket': 0.05; 'pypy': 0.07; 'referring': 0.07; 'skip:` 10': 0.07; 'implemented.': 0.09; 'indeed,': 0.09; 'name?': 0.09; 'namespace': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'url:pypy': 0.09; 'python': 0.11; '*a*': 0.16; ':-(': 0.16; '__builtin__': 0.16; 'kern': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'robert,': 0.16; 'sad': 0.16; 'shorten': 0.16; 'tracing': 0.16; 'url:py': 0.16; 'wrote:': 0.18; 'else,': 0.19; 'written': 0.21; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'fine': 0.24; "i've": 0.25; 'developers': 0.25; 'header:X-Complaints-To:1': 0.27; 'idea': 0.28; "doesn't": 0.30; 'robert': 0.30; 'code': 0.31; 'too.': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'subject:what': 0.31; 'anyone': 0.31; 'run': 0.32; 'url:python': 0.33; 'implemented': 0.33; 'skip:_ 10': 0.34; 'tool': 0.35; 'but': 0.35; 'there': 0.35; 'i.e.': 0.36; 'interface,': 0.36; 'library.': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'implement': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'quote': 0.39; 'supporting': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'helps': 0.61; 'profile': 0.61; 'name': 0.63; 'different': 0.65; 'production': 0.68; 'detail.': 0.68; 'past.': 0.68; 'repeat': 0.74; 'desperate': 0.84; 'received:139': 0.84; 'subject:skip:l 10': 0.84; 'profile.': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Neal Becker Subject: Re: line_profiler: what am I doing wrong? Date: Fri, 13 Feb 2015 08:33:15 -0500 References: <54daa1d6$0$12979$c3e8da3$5496439d@news.astraweb.com> <54daada4$0$12998$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: exa2-in-fw-01-epn.hns.com User-Agent: KNode/4.14.3 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: 52 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1423834414 news.xs4all.nl 2861 [2001:888:2000:d::a6]:51744 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85640 Robert Kern wrote: > On 2015-02-11 01:17, Steven D'Aprano wrote: >> Neal Becker wrote: >> >> >>> To quote from https://pypi.python.org/pypi/line_profiler/ >>> >>> $ kernprof -l script_to_profile.py >>> kernprof will create an instance of LineProfiler and insert it into the >>> __builtins__ namespace with the name profile. >> >> Ewww!!!! What a Ruby-esque interface, that makes me sad :-( > > This is not a production library. It's a development tool designed to > help developers shorten the cycle time for investigating these kinds of > issues. Well, *a* developer; i.e. me. If it helps anyone else, yahtzee! > >> And what if you >> have your own profile global name? > > Then you can pull it out from __builtin__ with a different name and use that > other name. > >> And *wrong* too. `__builtins__` is a private CPython implementation detail. >> The way to monkey-patch the built-ins in Python 2 is to inject the object >> into `__builtin__` (no s), or `builtins` in Python 3. > > And indeed that is how it is implemented. Referring to that namespace as the > "`__builtins__` namespace" isn't *wrong*. It may mislead you into thinking > I've implemented it one particular way, if you are desperate to find a nit to > pick. > >> Seeing as >> line_profiler is written in C, perhaps the author (Robert Kern) doesn't >> care about supporting Jython or IronPython, but there may be Python >> implementations (PyPy perhaps?) which can run C code but don't have >> __builtins__. > > Indeed, I do not care about any of them. PyPy does not implement CPython's > tracing API: > > https://bitbucket.org/pypy/pypy/src/2b2163d65ee437646194a1ceb2a3153db24c5f7e/pypy/module/cpyext/stubs.py?at=default#cl-1286 > Hi Robert, any idea why line_profiler is not working? I've used it fine in the past. -- -- Those who don't understand recursion are doomed to repeat it