On 04/05/18 22:38, Ian Kelly wrote: > On Fri, May 4, 2018 at 11:04 AM, Steven D'Aprano > <steve+comp.lang.pyt...@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.pyt...@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. >
Is it though? https://github.com/python/cpython/blob/a1fc949b5ab8911a803eee691e6eea55cec43eeb/Lib/operator.py#L265 -- https://mail.python.org/mailman/listinfo/python-list