Fastpath for encoding unsorted dict to JSON #95385
Labels
3.12
bugs and security fixes
performance
Performance or resource usage
type-feature
A feature request or enhancement
JSON encoder can produce output sorted by key (
json.dumps(sort_keys=True)
) The default value forsort_keys
isFalse
. The code always creates a list of dictionary items, sorts them if needed, and then iterates through them.However, if sorting is not requested we can use
PyDict_Next
to avoid allocating a list of tuples.pyperformance on my machine before changes:
pyperformance after changes:
The text was updated successfully, but these errors were encountered: