New submission from Wouter Bolsterlee:

The JSON encoder uses a lambda function for the sort(key=...) invocation used 
to sort the keys in a JSON object in case sort_keys=True is passed:

https://hg.python.org/cpython/file/46bfddb14cbe/Lib/json/encoder.py#l352

Instead of having a lambda, operator.itemgetter(0) can be used here, which is a 
minor performance gain. It should be noted that many other internals of the 
JSON encoder have also been fine-tuned (manually) for performance reasons.

----------
components: Library (Lib)
messages: 236302
nosy: wbolster
priority: normal
severity: normal
status: open
title: optimize sort_keys in json module by using operator.itemgetter()
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23493>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to