[Numpy-discussion] Profiling with cProfile

Robert Kern robert.kern@gmail....
Mon Feb 9 16:44:14 CST 2009

On Mon, Feb 9, 2009 at 15:35, Simon Palmer <simon.palmer@gmail.com> wrote:
> Hi,
> I am trying to profile a bit of code I have written using cProfile.  When I
> run it I get the message:
> TypeError: unhashable type: 'numpy.ndarray'
> I am using runctx with some local variables which are ndarrays.
> I am guessing that this is a lmitation of either cProfile or numpy or the
> mix of the two.  What is the recommended approach for profiling my code
> containing ndarrays?

You might try using runcall() instead. I'm not really familiar with
what cProfile may be doing in runctx() that will make it try to use
objects in the namespace as keys in a dict.

You may want to take a look at my kernprof.py script which is a useful
driver script for profiling any Python script without your having to
bother with making your own driver script.


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 Numpy-discussion mailing list