Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #85536

Re: line_profiler: what am I doing wrong?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; '"""': 0.07; 'skip:" 60': 0.07; 'inserted': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; 'wrote': 0.14; 'kern': 0.16; 'nameerror:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'underlying': 0.16; 'wrote:': 0.18; 'module': 0.19; 'written': 0.21; 'example': 0.22; 'header :User-Agent:1': 0.23; 'interpret': 0.24; 'skip:l 30': 0.24; 'skip:" 30': 0.26; 'pass': 0.26; 'defined': 0.27; 'skip:" 20': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'robert': 0.30; "skip:' 10": 0.31; 'subject:what': 0.31; 'trivial': 0.31; 'way?': 0.31; 'file': 0.32; '(most': 0.33; 'minimal': 0.33; 'something': 0.35; 'i.e.': 0.36; 'subject:?': 0.36; 'wrong': 0.37; 'work?': 0.38; 'to:addr:python- list': 0.38; 'anything': 0.39; 'recent': 0.39; 'does': 0.39; 'skip:. 10': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'even': 0.60; 'profile': 0.61; 'complete': 0.62; 'name': 0.63; 'our': 0.64; 'world': 0.66; 'believe': 0.68; 'results': 0.69; 'eco': 0.84; 'subject:skip:l 10': 0.84; 'terrible': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Robert Kern <robert.kern@gmail.com>
Subject Re: line_profiler: what am I doing wrong?
Date Wed, 11 Feb 2015 15:44:54 +0000
References <mbe6ea$bl7$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 213.1.240.226
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:31.0) Gecko/20100101 Thunderbird/31.4.0
In-Reply-To <mbe6ea$bl7$1@ger.gmane.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.18660.1423669806.18130.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1423669806 news.xs4all.nl 2864 [2001:888:2000:d::a6]:40769
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:85536

Show key headers only | View raw


On 2015-02-11 00:06, Neal Becker wrote:
> I inserted
> @profile
> def run(...)
>
> into a module-level global function called 'run'.  Something is very wrong here.
> 1. profile results were written before anything even ran
> 2. profile is not defined?
>
>   kernprof -l ./test_unframed.py --lots --of --args ...
>
> Wrote profile results to test_unframed.py.lprof
> Traceback (most recent call last):
>    File "/home/nbecker/.local/bin/kernprof", line 9, in <module>
>      load_entry_point('line-profiler==1.0', 'console_scripts', 'kernprof')()
>    File "/home/nbecker/.local/lib/python2.7/site-packages/kernprof.py", line 221,
> in main
>      execfile(script_file, ns, ns)
>    File "./test_unframed.py", line 721, in <module>
>      @profile
> NameError: name 'profile' is not defined

Can you pare this down to a minimal complete example that fails in this way? 
Does a trivial module work? I.e.

"""
@profile
def run():
     pass

run()
"""

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: line_profiler: what am I doing wrong? Robert Kern <robert.kern@gmail.com> - 2015-02-11 15:44 +0000

csiph-web