Re: "optimizing out" getattr

2005-09-15 Thread jepler
If you are including C extensions, why not crib 2.5's implementation of operator.attrgetter? It looks like it is fairly modular. http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Modules/operator.c Jeff pgpRT2RI9BoLZ.pgp Description: PGP signature -- http://mail.python.org/mailman/

Re: "optimizing out" getattr

2005-09-15 Thread Daishi Harada
Peter Otten wrote: > No, you can just sit back and wait -- for Python 2.5: Thanks for the tip; Although for my current use I can't target 2.5, I hadn't even noticed the attr/itemgetter additions to operator in 2.4, so I appreciate the pointer for future reference. d > $ cat attr_tuple25.py > impo

Re: "optimizing out" getattr

2005-09-15 Thread Kent Johnson
Peter Otten wrote: > Daishi Harada wrote: > > >>I'd like to get the 'get2' function below to >>perform like the 'get1' function (I've included >>timeit.py results). > > > >>labels = ('a', 'b') >>def get1(x): >>return (x.a, x.b) >>def mkget(attrs): >>def getter(x): >>return tu

Re: "optimizing out" getattr

2005-09-15 Thread Peter Otten
Daishi Harada wrote: > I'd like to get the 'get2' function below to > perform like the 'get1' function (I've included > timeit.py results). > labels = ('a', 'b') > def get1(x): > return (x.a, x.b) > def mkget(attrs): > def getter(x): > return tuple(getattr(x, label) for label in

Re: "optimizing out" getattr

2005-09-14 Thread Stephen Thorne
On 14 Sep 2005 19:46:44 -0700, Daishi Harada <[EMAIL PROTECTED]> wrote: > Hi, > > I'd like to get the 'get2' function below to > perform like the 'get1' function (I've included > timeit.py results). Do you have profiling results that show that a significant percentage of your programs time is be

"optimizing out" getattr

2005-09-14 Thread Daishi Harada
Hi, I'd like to get the 'get2' function below to perform like the 'get1' function (I've included timeit.py results). I'm not sure how to write 'mkget' to do achieve this, however, except to use 'exec' - is that what would be necessary? Thanks in advance, d --- class A: a = 1 b = 2 a = A