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


Groups > comp.lang.python > #85492

Re: line_profiler: what am I doing wrong?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!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 <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.018
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; '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; '~ethan~': 0.09; 'def': 0.12; 'wrote': 0.14; 'nameerror:': 0.16; 'namespace,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'working.': 0.19; 'written,': 0.19; 'written': 0.21; 'header :User-Agent:1': 0.23; 'received:comcast.net': 0.24; 'skip:l 30': 0.24; 'skip:" 30': 0.26; 'defined': 0.27; 'skip:" 20': 0.27; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; "i'm": 0.30; "skip:' 10": 0.31; 'subject:what': 0.31; 'file': 0.32; 'supposed': 0.32; '(most': 0.33; 'guess': 0.33; 'something': 0.35; 'but': 0.35; 'subject:?': 0.36; 'should': 0.36; 'wrong': 0.37; 'being': 0.38; 'received:76': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'anything': 0.39; 'recent': 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; 'first': 0.61; 'name': 0.63; 'due': 0.66; 'believe': 0.68; 'results': 0.69; 'repeat': 0.74; 'ethan': 0.84; 'furman': 0.84; 'subject:skip:l 10': 0.84; 'apparent': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Neal Becker <ndbecker2@gmail.com>
Subject Re: line_profiler: what am I doing wrong?
Date Tue, 10 Feb 2015 19:18:56 -0500
References <mbe6ea$bl7$1@ger.gmane.org> <54DA9E37.9090602@stoneleaf.us>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host c-76-100-246-88.hsd1.md.comcast.net
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 <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.18638.1423613950.18130.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1423613950 news.xs4all.nl 2937 [2001:888:2000:d::a6]:33501
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:85492

Show key headers only | View raw


Ethan Furman wrote:

> On 02/10/2015 04:06 PM, 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
> 
> I'm going to guess that writing the profile results is in a try/finally -- so
> first you see the results being written, then the exception that triggered.
> 
> --
> ~Ethan~

I believe you are suggesting the apparent out-of-order is due to try/finally, 
but kernprof is supposed to inject 'profile' into the global namespace, so 
@profile should be defined - I don't know why it isn't working.

-- 
-- Those who don't understand recursion are doomed to repeat it

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


Thread

Re: line_profiler: what am I doing wrong? Neal Becker <ndbecker2@gmail.com> - 2015-02-10 19:18 -0500

csiph-web