From: Robert K. <rob...@gm...> - 2006-10-19 15:57:01
|
Travis Oliphant wrote: > I just learned about how to allow built-ins to have attributes assigned > to their instances. It's actually pretty easy because of Python > support for it --- but it comes at a cost. You have to add a dictionary > to the PyArrayObject structure, create that dictionary when the ndarray > is allocated, and set the tp_dictoffset in the TypeObject structure to > its location in PyArrayObject. It takes 4 lines of code with the cost of > creating a new dictionary for every ndarray. > > I don't think the extra bytes for every ndarray object are worth it, > given how easy it is to sub-class and create your own ndarray that can > have attributes attached. What are others opinions. I'd say leave it off. Many uses of that feature will require custom __array_finalize__ methods anyways. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |