This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients josh.r, rhettinger, wbolster
Date 2015-02-23.01:13:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I'm -0 on this proposal.

There is a small speed-up to be had here:

  $ python3.4 -m timeit -s 'f=lambda kv: kv[0]' -s 's=[10, 20]' 'f(s)'
  10000000 loops, best of 3: 0.105 usec per loop

  $ python3.4 -m timeit -s 'import operator' -s 'f=operator.itemgetter(0)' -s 's=[10, 20]' 'f(s)'
  10000000 loops, best of 3: 0.0717 usec per loop

That said, it is applied only n-times and is likely insignificant when compared to the O(n log n) sort.   I think it is better to not add an intermodule dependency when we don't have to.

Also if you're using CPython, then the C version of JSON is used instead of this code.  So, any timings or optimizations should be tested against the other implementations (Jython or PyPy) that use them.   In those implementations, I don't think itemgetter() has any performance benefit over the lambda.
Date User Action Args
2015-02-23 01:13:16rhettingersetrecipients: + rhettinger, wbolster, josh.r
2015-02-23 01:13:16rhettingersetmessageid: <>
2015-02-23 01:13:16rhettingerlinkissue23493 messages
2015-02-23 01:13:16rhettingercreate