[Numpy-discussion] Record arrays

Stéfan van der Walt stefan@sun.ac...
Thu Jul 3 02:34:46 CDT 2008

2008/6/27 Fernando Perez <fperez.net@gmail.com>:
> On Thu, Jun 26, 2008 at 1:25 PM, Robert Kern <robert.kern@gmail.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
> dtypes:
> In [13]: r['foo']
> Out[13]: array([1, 1, 1])
> In [14]: r.f.foo
> -> Hypothetically, same as [13] 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 mailing list