[Numpy-discussion] Record arrays
Stéfan van der Walt
Thu Jul 3 02:34:46 CDT 2008
2008/6/27 Fernando Perez <firstname.lastname@example.org>:
> On Thu, Jun 26, 2008 at 1:25 PM, Robert Kern <email@example.com> wrote:
>> One downside of this is that the attribute access feature slows down
>> all field accesses, even the r['foo'] form, because it sticks a bunch
>> of pure Python code in the middle. Much code won't notice this, but if
>> you end up having to iterate over an array of records (as I have),
>> this will be a hotspot for you.
> I wonder if it wouldn't be useful for *all* numpy arrays to have a .f
> attribute that would provide attribute access to fields for complex
> In : r['foo']
> Out: array([1, 1, 1])
> In : r.f.foo
> -> Hypothetically, same as  above
I like this idea, and think it is worth exploring further. It would
have been even better if we could have done
Unfortunately, there is no way (I know of) to tell `f` whether
getattribute is being called further down the chain.
But even having x.f.field.f.subfield would already be useful.
More information about the Numpy-discussion