[SciPy-dev] Records module

Travis Oliphant oliphant at ee.byu.edu
Thu Dec 1 14:00:17 CST 2005

Recent SVN has the changes to the ndarray object to allow getfield to 
also receive a tuple for the data type.   A tuple for the data-type in 
getfield implies that the field is a sub-array.  The returned array has 
this sub-array tacked on to the end of the shape (no data ever gets 
moved around for field access, just the way it is viewed...)

With this change, I see being able to make record arrays essentially 
just a map between field names and a (type, offset) pair --- where type 
may itself be a tuple (actual type, shape). 

Additionally:  It's fine to have a field method, I suppose, but would it 
be possible to also do it with properties?

For each field name create a (dynamic) property with that name.  The get 
property code maps the name to the (type, offset) pair using the stored 
dictionary and uses getfield to extract that particular field.

I'm not sure if dynamic properties are possible, or if some other 
attribute access would have to be implemented.  But it's something to 
look into.


More information about the Scipy-dev mailing list