[Numpy-discussion] recarray slow?
Wed Jul 21 15:35:21 CDT 2010
idx_by_name = dict(enumerate(d.dtype.names))
Then I can look up the index of the columns I want before the loop,
and then access by the index during the loop.
On Wed, Jul 21, 2010 at 4:29 PM, Pierre GM <firstname.lastname@example.org> wrote:
> 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.
> NumPy-Discussion mailing list
More information about the NumPy-Discussion