[Numpy-discussion] Proposed record array behavior: the rest of the story: updated
Russell E Owen
rowen at u.washington.edu
Tue Jul 27 13:44:02 CDT 2004
At 5:41 PM -0400 2004-07-26, Colin J. Williams wrote:
>Russell E Owen wrote:
>> At 11:43 AM -0400 2004-07-26, Perry Greenfield wrote:
>>> I'll try to see if I can address all the comments raised (please
>>>let me know
>>> if I missed something).
>>> ...(nice proposal elided)...
>>> Any comments on these changes to the proposal? Are there those that are
>>> opposed to supporting attribute access?
>> Overall this sounds great.
>> However, I am still strongly against attribute access.
>> Attributes are usually meant for names that are intrinsic to the
>>design of an object, not to the user's "configuration" of the
>Russell, I hope that you will elaborate this distinction between
>design and usage. On the face of it, I would have though that the
>two should be closely related.
To my mind, the design of an object describes the intended behavior
of the object: what kind of data can it deal with and what should it
do to that data. It tends to be "static" in the sense that it is not
a function of how the object is created or what data is contained in
the object. The design of the object usually drives the choice of the
attributes of the object (variables and methods).
On the other hand, the user's "configuration" of the object is what
the user has done to make a particular instance of an object unique
-- the data the user has been loaded into the object.
I consider the particular named fields of a record array to fall into
the latter category. But it is a gray area. Somebody else might argue
that the record array constructors is an object factory, turning out
an object designed by the user. From that alternative perspective,
adding attributes to represent field names is perhaps more natural as
I think the main issues are:
- Are there too many ways to address things? (I say yes)
- Field name mapping: there is no trivial 1:1 mapping between valid
field names and valid attribute names.
- Nested access. Not sure about this one, but I'd like to hear more.
If we do end up with attributes for field names, I really like Rick
White's suggestion of adding an attribute for a field only if the
field name is already a valid attribute name. That neatly avoids the
collision issue and is simple to document.
More information about the Numpy-discussion