[Python-3000] Need closure on __cmp__ removal

Oleg Broytmann phd at phd.pp.ru
Wed Jan 9 20:41:29 CET 2008


On Wed, Jan 09, 2008 at 11:34:59AM -0800, Brett Cannon wrote:
> On Jan 9, 2008 11:34 AM, Oleg Broytmann <phd at phd.pp.ru> wrote:
> >    newlist = oldlist.sort(key=lambda v: v.attr_x)
> 
> And don't forget about operator.attrgetter().

   I don't like it for the task. To use I need to import operator, and
I don't know is it faster or slower than lambda; I suspect it's slower but
I am too lazy to test. Using lambda to get a simple attribute seems much
simpler to me.

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.


More information about the Python-3000 mailing list