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


Groups > comp.lang.python > #6211

Re: Hotshoting recursive function

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.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.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'function,': 0.07; 'suggestions.': 0.07; 'python': 0.08; 'decorator': 0.09; 'interpreting': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'recipe': 0.09; 'url:activestate': 0.09; 'syntax': 0.11; 'def': 0.12; 'anymore.': 0.16; 'from:addr:yahoo.com.ar': 0.16; 'recursive': 0.16; 'subject:function': 0.16; 'url:code': 0.17; 'guess': 0.19; 'function': 0.25; 'raise': 0.28; 'module': 0.30; 'sun,': 0.30; 'header:X-Complaints-To:1': 0.32; 'does': 0.33; 'to:addr:python- list': 0.33; '...': 0.34; 'header:User-Agent:1': 0.35; 'skip:" 10': 0.35; 'function.': 0.35; 'using': 0.35; 'convenient': 0.37; 'received:org': 0.38; 'data': 0.38; 'subject:: ': 0.38; 'some': 0.38; 'should': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'getting': 0.40; 'your': 0.60; 'details': 0.64; 'due': 0.67; 'works,': 0.68; 'profile': 0.70; 'received:190': 0.74; '-0300,': 0.84; 'genellina': 0.84; 'profiling': 0.84; 'gabriel': 0.91; 'you...': 0.95
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From "Gabriel Genellina" <gagsl-py2@yahoo.com.ar>
Subject Re: Hotshoting recursive function
Date Wed, 25 May 2011 05:50:44 -0300
References <BANLkTikAot0gqxsBHwDbRxj2LaHmrsZ=HQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=iso-8859-1; format=flowed; delsp=yes
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host 190.2.4.25
User-Agent Opera Mail/11.11 (Win32)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2060.1306313281.9059.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 82.94.164.166
X-Trace 1306313282 news.xs4all.nl 49038 [::ffff:82.94.164.166]:57632
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6211

Show key headers only | View raw


En Sun, 22 May 2011 10:42:08 -0300, Selvam <s.selvamsiva@gmail.com>  
escribió:

> I am using  hotshot module to profile my python function.
>
> I used the details from (
> http://code.activestate.com/recipes/576656-quick-python-profiling-with-hotshot/
> ).
>
> The function I profile is a recursive one and I am getting the following
> error,
>
> "ProfilerError: profiler already active"
>
> I guess this is due to the recursive call to the profiling function.
>
> I would like to get some suggestions.

The recursive call inside your function should call the undecorated  
function, not the decorated function again. Decorator syntax is not  
convenient anymore.

Using the same names as in the recipe example:


# a recursive function
def my_slow_function(n):
   ...
   return my_slow_function(n-1)


my_profiled_slow_function = hotshotit(my_slow_function)
my_profiled_slow_function(n)


This works, in the sense that it does not raise ProfileError anymore.  
Interpreting profile data is up to you...


-- 
Gabriel Genellina

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


Thread

Re: Hotshoting recursive function "Gabriel Genellina" <gagsl-py2@yahoo.com.ar> - 2011-05-25 05:50 -0300

csiph-web