Message236423
| Author |
rhettinger |
| Recipients |
josh.r, rhettinger, wbolster |
| Date |
2015年02月23日.01:13:16 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1424653996.94.0.22277308669.issue23493@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2015年02月23日 01:13:16 | rhettinger | set | recipients:
+ rhettinger, wbolster, josh.r |
| 2015年02月23日 01:13:16 | rhettinger | set | messageid: <1424653996.94.0.22277308669.issue23493@psf.upfronthosting.co.za> |
| 2015年02月23日 01:13:16 | rhettinger | link | issue23493 messages |
| 2015年02月23日 01:13:16 | rhettinger | create |
|