| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Optimize json encoder for floats: up to 1.3x faster. Avoid creating a temporary Unicode object when writing the JSON representation of a float: decode directly the ASCII-encoded string (PyOS_double_to_string()) into the writer.
|
Benchmark: import pyperf
runner = pyperf.Runner()
for list_len in (1, 10, 100, 1000):
runner.timeit(f'encode list of {list_len} floats',
setup=f'import json; L=[1.0] * {list_len}; dumps=json.dumps',
stmt='dumps(L)')Results:
|
Sorry, something went wrong.
|
I compared the performance on jsonyx (because I didn't want to re-build CPython):
|
Sorry, something went wrong.
Co-authored-by: Maxim Martynov <martinov_m_s_@mail.ru>
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Optimize json encoder for floats: up to 1.3x faster.
Avoid creating a temporary Unicode object when writing the JSON representation of a float: decode directly the ASCII-encoded string (PyOS_double_to_string()) into the writer.