[Numpy-discussion] recarray slow?

Robert Kern robert.kern at gmail.com
Wed Jul 21 15:37:29 EDT 2010


On Wed, Jul 21, 2010 at 15:12, wheres pythonmonks
<wherespythonmonks at gmail.com> wrote:
> I have an recarray -- the first column is date.
>
> I have the following function to compute the number of unique dates in
> my data set:
>
>
> def byName(): return(len(list(set(d['Date'])) ))
>
> Question:  is the string 'Date' looked up at each iteration?  If so,
> this is dumb, but explains my horrible performance.
> Or, is there a better way to code the above?

len(np.unique(d['Date']))

If you can come up with a self-contained example that we can
benchmark, it would help. In my examples, I don't see any hideous
performance, but my examples may be missing some crucially important
detail about your data that is causing your performance problems.

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