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

Robert Kern robert.kern at gmail.com
Sat Sep 30 15:59:45 EDT 2006


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

-- 
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



More information about the SciPy-User mailing list