itemgetter with default arguments

Ian Kelly ian.g.kelly at gmail.com
Fri May 4 16:38:54 EDT 2018


On Fri, May 4, 2018 at 11:04 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> 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.

I saw that. I just don't understand why the solution should require a
lambda just because that was the word used by a couple of core devs.

> 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.

The real thing is written in C.



More information about the Python-list mailing list