![](https://secure.gravatar.com/avatar/55f7acf47233a7a98f5eb9dfd0b2d763.jpg?s=120&d=mm&r=g)
After a fashion anyway. I implemented the simplest thing that could possibly work and I've left out some stuff that even I think we need (docstring, repr and str). Still it exists, ndarray inherits from it and some stuff seems to work automagically.
Travis: should I go ahead and check this into the trunk? It shouldn't interfear with anything. The only change to ndarray is the tp_base, which sets up the inheritance. -tim
![](https://secure.gravatar.com/avatar/837d314801b4f1400d6eabc767ca2cac.jpg?s=120&d=mm&r=g)
Let me add my $.02. I am very much in favor of a basic array object. I would probably go much further than Tim in simplifying it. No need for repr/str. No number protocol. No sequence/mapping protocol either. Maybe even no dimensions/striding etc. What is left? Not much on top of buffer protocol: the type description. I've expressed this opinion several times before (and was criticised for not supporting it:-): I don't think a basearray should be a base class. The main reason is that in most cases subclasses will need to adapt all the array methods. In many cases (speaking from ma experience, but probably matrix folks can relate) the adaptation is not automatic and has to be done on the method by method bases. Exposure of the base class methods without adaptation or with wrong adaptation leads to errors. Unless the base array is truly minimalistic and stays this way, methods that are added to the base class in the future will likely not work unadapted. The only implementation that uses inheritance that I will like would be something similar to python's object type: rich C API and no Python API. Would you consider checking your implementation in without modifying ndarray's tp_base? On 4/30/06, Tim Hochberg <tim.hochberg@cox.net> wrote:
![](https://secure.gravatar.com/avatar/49df8cd4b1b6056c727778925f86147a.jpg?s=120&d=mm&r=g)
Tim Hochberg wrote:
I say go ahead. We can then all deal with it there and improve upon it. The ndarray used to inherit from another array and things worked. Python's inheritance in C is actually quite slick. Especially for structural issues. I agree that the basearray should have minimal operations (I would not even define several of the protocols for it). I'd probably only keep the buffer and mapping protocol but even then probably only a simple mapping protocol (i.e. no fancy-indexing) that then gets enhanced by the ndarray. Thanks for the work. -Travis
![](https://secure.gravatar.com/avatar/837d314801b4f1400d6eabc767ca2cac.jpg?s=120&d=mm&r=g)
Let me add my $.02. I am very much in favor of a basic array object. I would probably go much further than Tim in simplifying it. No need for repr/str. No number protocol. No sequence/mapping protocol either. Maybe even no dimensions/striding etc. What is left? Not much on top of buffer protocol: the type description. I've expressed this opinion several times before (and was criticised for not supporting it:-): I don't think a basearray should be a base class. The main reason is that in most cases subclasses will need to adapt all the array methods. In many cases (speaking from ma experience, but probably matrix folks can relate) the adaptation is not automatic and has to be done on the method by method bases. Exposure of the base class methods without adaptation or with wrong adaptation leads to errors. Unless the base array is truly minimalistic and stays this way, methods that are added to the base class in the future will likely not work unadapted. The only implementation that uses inheritance that I will like would be something similar to python's object type: rich C API and no Python API. Would you consider checking your implementation in without modifying ndarray's tp_base? On 4/30/06, Tim Hochberg <tim.hochberg@cox.net> wrote:
![](https://secure.gravatar.com/avatar/49df8cd4b1b6056c727778925f86147a.jpg?s=120&d=mm&r=g)
Tim Hochberg wrote:
I say go ahead. We can then all deal with it there and improve upon it. The ndarray used to inherit from another array and things worked. Python's inheritance in C is actually quite slick. Especially for structural issues. I agree that the basearray should have minimal operations (I would not even define several of the protocols for it). I'd probably only keep the buffer and mapping protocol but even then probably only a simple mapping protocol (i.e. no fancy-indexing) that then gets enhanced by the ndarray. Thanks for the work. -Travis
participants (3)
-
Sasha
-
Tim Hochberg
-
Travis Oliphant