Re: [Numpy-discussion] ndarray __getattr__ to perform __getitem__

2010-10-29 Thread Pauli Virtanen
Fri, 29 Oct 2010 09:58:33 -0400, Ian Stokes-Rees wrote: [clip] > I've spent an hour looking at the numpy code (my first time), and I > don't see any obvious way to do this, since ndarray is (AFAICT) a pure-C > object with auto-generated wrappers, which seems to preclude (easily) > adding a "__getat

Re: [Numpy-discussion] ndarray __getattr__ to perform __getitem__

2010-10-29 Thread Pierre GM
On Oct 29, 2010, at 3:58 PM, Ian Stokes-Rees wrote: > >> Note that there are various extant projects that I think attempt to >> provide similar functionality to what you're wanting (unless I badly >> misread your original email, in which case apologies): >> http://projects.scipy.org/numpy/wi

Re: [Numpy-discussion] ndarray __getattr__ to perform __getitem__

2010-10-29 Thread Ian Stokes-Rees
> Note that there are various extant projects that I think attempt to > provide similar functionality to what you're wanting (unless I badly > misread your original email, in which case apologies): > http://projects.scipy.org/numpy/wiki/NdarrayWithNamedAxes Having looked into it more, I think

Re: [Numpy-discussion] ndarray __getattr__ to perform __getitem__

2010-10-29 Thread Zachary Pincus
>>> But wouldn't the performance hit only come when I use it in this >>> way? >>> __getattr__ is only called if the named attribute is *not* found (I >>> guess it falls off the end of the case statement, or is the result >>> of >>> the attribute hash table "miss"). >> That's why I said that __g

Re: [Numpy-discussion] ndarray __getattr__ to perform __getitem__

2010-10-29 Thread Pauli Virtanen
Hi, Fri, 29 Oct 2010 05:59:07 -0400, Ian Stokes-Rees wrote: >>> But wouldn't the performance hit only come when I use it in this way? >>> __getattr__ is only called if the named attribute is *not* found (I >>> guess it falls off the end of the case statement, or is the result of >>> the attribute

Re: [Numpy-discussion] ndarray __getattr__ to perform __getitem__

2010-10-29 Thread Ian Stokes-Rees
>> But wouldn't the performance hit only come when I use it in this way? >> __getattr__ is only called if the named attribute is *not* found (I >> guess it falls off the end of the case statement, or is the result of >> the attribute hash table "miss"). > That's why I said that __getattr__ would p

Re: [Numpy-discussion] ndarray __getattr__ to perform __getitem__

2010-10-28 Thread Robert Kern
On Thu, Oct 28, 2010 at 16:37, Ian Stokes-Rees wrote: > > > On 10/28/10 5:29 PM, Robert Kern wrote: >> On Thu, Oct 28, 2010 at 15:17, Ian Stokes-Rees >> wrote: >>> I have an ndarray with named dimensions.  I find myself writing some >>> fairly laborious code with lots of square brackets and quote

Re: [Numpy-discussion] ndarray __getattr__ to perform __getitem__

2010-10-28 Thread Ian Stokes-Rees
On 10/28/10 5:29 PM, Robert Kern wrote: > On Thu, Oct 28, 2010 at 15:17, Ian Stokes-Rees > wrote: >> I have an ndarray with named dimensions. I find myself writing some >> fairly laborious code with lots of square brackets and quotes. It seems >> like it wouldn't be such a big deal to overload

Re: [Numpy-discussion] ndarray __getattr__ to perform __getitem__

2010-10-28 Thread Robert Kern
On Thu, Oct 28, 2010 at 15:17, Ian Stokes-Rees wrote: > I have an ndarray with named dimensions.  I find myself writing some > fairly laborious code with lots of square brackets and quotes.  It seems > like it wouldn't be such a big deal to overload __getattribute__ so > instead of doing: > > r =