itemgetter with default arguments

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri May 4 13:04:31 EDT 2018


On Fri, 04 May 2018 09:17:14 -0600, Ian Kelly wrote:

> On Fri, May 4, 2018 at 7:01 AM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
>> Here are the specifications:
>>
>> * you must use lambda, not def;
> 
> Why? This seems like an arbitrary constraint.

You'll have to ask the two core devs. In my post, in the part you 
deleted, I wrote:

    Two senior developers have rejected this feature, saying 
    that we should just use a lambda instead.


My guess is that they were thinking that there's no need to complicate 
itemgetter for this use-case when it is just as easy to write up a quick 
lambda to do the job.

For what it's worth, your itemgetter2() is about 1600% slower on my 
computer than the real thing. I know I didn't specify speed as a 
requirement, but I mention it because on the bug tracker, the importance 
of keeping itemgetter fast is stressed.




-- 
Steve




More information about the Python-list mailing list