[issue23493] optimize sort_keys in json module by using operator.itemgetter()

Josh Rosenberg report at bugs.python.org
Sat Feb 21 01:43:21 CET 2015


Josh Rosenberg added the comment:

Is it even legal to have non-string keys in a JSON object? If they must be strings, and they must be unique, I don't think a key argument is necessary (and it would save the generation of the key array; not doing the work is faster than doing the work more efficiently after all), since the default tuple comparison would work fine; the first element would always be unequal, so the second elements would never be compared, right?

I'm not 100% on this with the rich comparison operator approach, but my attempts to trigger a failure haven't worked (TimSort or the tuple comparison, or both, are probably smarter about this than I am).

----------
nosy: +josh.r

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23493>
_______________________________________


More information about the Python-bugs-list mailing list