[Numpy-discussion] recarray slow?

Pierre GM pgmdevlist@gmail....
Wed Jul 21 15:29:54 CDT 2010


On Jul 21, 2010, at 4:22 PM, wheres pythonmonks wrote:

> However: is there an automatic way to convert a named index to a position?
> 
> What about looping over tuples of my recarray:
> 
> for t in d:
>    date = t['Date']
>    ....

Why don't you use zip ?

>>> for (date, t) in (d['Date'], d)

That way, you save repetitive calls to __getitem__....

> Should I create a map from dtype.names(), and use that to look up the
> index based on the name in advance?  (if I really really want to
> factorize out the lookup of 'Date']


Meh. I have a bad feeling about it that it won't be really performant.



More information about the NumPy-Discussion mailing list