[SciPy-user] Pros and Cons of Python verses other array environments

David Cournapeau david at ar.media.kyoto-u.ac.jp
Tue Oct 3 00:52:19 CDT 2006

Robert Kern wrote:
> David Cournapeau wrote:
>> You have first an index on all top level functions, and you can dig it 
>> through as deep as you want. Notice how you know for a given function 
>> which call are called when and how often. I have no idea how difficult 
>> this would be to implement in python. I was told some months ago on the 
>> main python list that hotshot can give a per line profiling of python 
>> code, but this is not documented; also, it looks like it is possible to 
>> get the source code at runtime without too much difficulty in python. I 
>> would be really surprised if nobody tried to do something similar for 
>> python in general, because this is really useful. I have never found 
>> anything for python, but it may be just because I don't know the name 
>> for this kind of tools (I tried googling with terms such as "source 
>> profiling", without much success).
> One excellent tool for drilling through these results is a KDE application 
> called kcachegrind. It was written to visualize valgrind profiling results, but 
> the file format is generic enough that someone wrote a script hotshot2calltree 
> that converts hotshot results to it. I believe it comes with kcachegrind.
>    http://kcachegrind.sourceforge.net/cgi-bin/show.cgi
> There is a new profiler the comes with 2.5 (but I believe is compatible with at 
> least 2.4) called cProfile (available separately as lsprof). It too has a 
> converter for kcachegrind.
>    http://codespeak.net/svn/user/arigo/hack/misc/lsprof/
>    http://www.gnome.org/~johan/lsprofcalltree.py

Thanks for the tip: it looks like lsprof can gives you the information 
per child functions, which is the main weakness of previous python 
profilers IMHO. I cannot make it work right now on python2.4, will try 
at home with python 2.5


More information about the SciPy-user mailing list