[Numpy-discussion] Addition of a dict object to all NumPy objects

Travis E. Oliphant oliphant at enthought.com
Fri Aug 15 17:12:43 EDT 2008


Robert Kern wrote:
>
>>>> 3) Are the additional 4-8 bytes too expensive
>>>>         
>>> One of the problems with numarray was the time taken to allocate small
>>> arrays. Would adding a dictionary slow down the allocation of numpy arrays?
>>>       
No, I don't think so,  not if we did nothing by default but set the dict 
to NULL (i.e. no propagation of meta-information to new arrays).
>> That said, I think we should keep things as simple and orthogonal as
>> possible. If we go this way, I think a subclass with a dictionary would be
>> the best approach to avoid the heartbreak of creeping featuritis.
>>     
>
> The point of the feature is to avoid subclasses. There are a number of
> use cases for annotating arrays with metadata. Currently, they are
> forced to use subclasses. Every time you use ndarray subclasses, you
> are essentially forcing yourself into your subclass's ghetto of
> functions that only work on your subclass.
>   
This would be one-step better in the sense that there would be a single 
sub-class to handle all cases of just needing meta information.    But, 
I tend to agree that adding the dictionary to all arrays is preferable.
> I think you could make the dictionary created lazily on the first getattr().
>   
Yes, that could easily be done.  It would just be set to NULL on 
creation and the penalty/overhead would be the extra pointer in the 
array structure.

-Travis






More information about the NumPy-Discussion mailing list