@@ -5,8 +5,8 @@ fastest Python library for JSON and has comprehensive unit, integration, and
55interoperability tests.
66
77Its serialization performance is 2x to 3x the nearest
8- other library and 4.5x to 11.5x the standard library. Its deserialization
9- performance is 0.95x to 1.1x the nearest other library and 1.2x to 3x
8+ other library and 4x to 12x the standard library. Its deserialization
9+ performance is 0.9x to 1.1x the nearest other library and 1.1x to 2x
1010the standard library.
1111
1212It differs in behavior from other Python JSON libraries in supporting
@@ -254,6 +254,12 @@ JSONEncodeError: Integer exceeds 53-bit max
254254JSONEncodeError: Integer exceeds 53 - bit max
255255```
256256
257+ ### float
258+
259+ orjson serializes and deserializes float values in a consistent way. The
260+ same behavior is observed in rapidjson, simplejson, and json. ujson is
261+ inaccurate in both serialization and deserialization.
262+
257263### UTF-8
258264
259265orjson raises an exception on invalid UTF-8. This is
@@ -329,84 +335,87 @@ format, containing floats and arrays, indented.
329335
330336| Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
331337| ------------| ---------------------------------| -------------------------| ----------------------|
332- | orjson | 0.49 | 2038.2 | 1 |
333- | ujson | 1.41 | 709.1 | 2.87 |
334- | rapidjson | 1.57 | 636.4 | 3.2 |
335- | simplejson | 2.69 | 370.5 | 5.49 |
336- | json | 2.6 | 384.6 | 5.3 |
338+ | orjson | 0.54 | 1854.5 | 1 |
339+ | ujson | 1.47 | 678.3 | 2.73 |
340+ | rapidjson | 1.58 | 634 | 2.92 |
341+ | simplejson | 2.7 | 369.3 | 5.01 |
342+ | json | 2.45 | 407.7 | 4.55 |
337343
338344#### twitter.json deserialization
339345
340346| Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
341347| ------------| ---------------------------------| -------------------------| ----------------------|
342- | orjson | 2.46 | 403.8 | 1 |
343- | ujson | 2.27 | 443 | 0.92 |
344- | rapidjson | 3.11 | 320.1 | 1.26 |
345- | simplejson | 2.48 | 401.9 | 1.01 |
346- | json | 2.85 | 350.8 | 1.16 |
348+ | orjson | 2.6 | 384.4 | 1 |
349+ | ujson | 2.33 | 427.2 | 0.89 |
350+ | rapidjson | 3.09 | 322 | 1.19 |
351+ | simplejson | 2.61 | 381.5 | 1 |
352+ | json | 2.91 | 342.1 | 1.12 |
347353
348354#### github.json serialization
349355
350356| Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
351357| ------------| ---------------------------------| -------------------------| ----------------------|
352- | orjson | 0.05 | 18670.2 | 1 |
353- | ujson | 0.14 | 7136.1 | 2.61 |
354- | rapidjson | 0.16 | 6384.5 | 2.92 |
355- | simplejson | 0.31 | 3192.2 | 5.82 |
356- | json | 0.27 | 3623 | 5.12 |
358+ | orjson | 0.06 | 16532.4 | 1 |
359+ | ujson | 0.14 | 6990.6 | 2.35 |
360+ | rapidjson | 0.16 | 6236.3 | 2.65 |
361+ | simplejson | 0.31 | 3234.9 | 5.1 |
362+ | json | 0.25 | 3943.4 | 4.19 |
357363
358364#### github.json deserialization
359365
360366| Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
361367| ------------| ---------------------------------| -------------------------| ----------------------|
362- | orjson | 0.2 | 4988.3 | 1 |
363- | ujson | 0.22 | 4525.8 | 1.11 |
364- | rapidjson | 0.27 | 3698.6 | 1.35 |
365- | simplejson | 0.23 | 4371.5 | 1.14 |
366- | json | 0.24 | 4114.8 | 1.21 |
368+ | orjson | 0.23 | 4395.8 | 1 |
369+ | ujson | 0.23 | 4431.2 | 0.99 |
370+ | rapidjson | 0.27 | 3746.8 | 1.18 |
371+ | simplejson | 0.22 | 4652.8 | 0.95 |
372+ | json | 0.25 | 3991.5 | 1.11 |
367373
368374#### citm_catalog.json serialization
369375
370376| Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
371377| ------------| ---------------------------------| -------------------------| ----------------------|
372- | orjson | 0.79 | 1261.8 | 1 |
373- | ujson | 2.61 | 381.6 | 3.31 |
374- | rapidjson | 2.48 | 402.4 | 3.14 |
375- | simplejson | 9.93 | 100.7 | 12.59 |
376- | json | 5.81 | 172 | 7.37 |
378+ | orjson | 0.81 | 1232 | 1 |
379+ | ujson | 2.78 | 359.1 | 3.43 |
380+ | rapidjson | 2.59 | 386 | 3.19 |
381+ | simplejson | 10.53 | 95.2 | 12.98 |
382+ | json | 5.41 | 184.7 | 6.67 |
377383
378384#### citm_catalog.json deserialization
379385
380386| Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
381387| ------------| ---------------------------------| -------------------------| ----------------------|
382- | orjson | 4.45 | 224.7 | 1 |
383- | ujson | 4.35 | 229.8 | 0.98 |
384- | rapidjson | 5.52 | 181.7 | 1.24 |
385- | simplejson | 6.11 | 163.1 | 1.37 |
386- | json | 6.02 | 165.6 | 1.35 |
388+ | orjson | 4.76 | 210.1 | 1 |
389+ | ujson | 4.39 | 228 | 0.92 |
390+ | rapidjson | 5.79 | 174.9 | 1.22 |
391+ | simplejson | 6.1 | 163.8 | 1.28 |
392+ | json | 6.03 | 165.7 | 1.27 |
387393
388394#### canada.json serialization
389395
390396| Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
391397| ------------| ---------------------------------| -------------------------| ----------------------|
392- | orjson | 4.21 | 237.7 | 1 |
393- | ujson | 8.42 | 118.4 | 2 |
394- | rapidjson | 43 .17 | 23.2 | 10.27 |
395- | simplejson | 62.6 | 16 | 14.89 |
396- | json | 47.93 | 20.9 | 11.4 |
398+ | orjson | 3.95 | 252.1 | 1 |
399+ | ujson | | | |
400+ | rapidjson | 44 .17 | 22.6 | 11.18 |
401+ | simplejson | 64.52 | 15.5 | 16.33 |
402+ | json | 47.01 | 21.3 | 11.9 |
397403
398404#### canada.json deserialization
399405
400406| Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
401407| ------------| ---------------------------------| -------------------------| ----------------------|
402- | orjson | 8.56 | 116.3 | 1 |
403- | ujson | 8.24 | 121.5 | 0.96 |
404- | rapidjson | 29.05 | 34.4 | 3.39 |
405- | simplejson | 26.85 | 37 | 3.14 |
406- | json | 27.45 | 36.4 | 3.21 |
408+ | orjson | 14.76 | 67.8 | 1 |
409+ | ujson | | | |
410+ | rapidjson | 29.01 | 34.5 | 1.97 |
411+ | simplejson | 26.75 | 37.4 | 1.81 |
412+ | json | 27.18 | 36.8 | 1.84 |
413+
407414
415+ If a row is blank, the library did not serialize and deserialize the fixture without
416+ modifying it, e.g., returning different values for floating point numbers.
408417
409- This was measured using Python 3.7.2 on Linux with orjson 2.0.3 , ujson 1.35,
418+ This was measured using Python 3.7.3 on Linux with orjson 2.0.5 , ujson 1.35,
410419python-rapidson 0.7.0, and simplejson 3.16.0.
411420
412421The results can be reproduced using the ` pybench ` and ` graph ` scripts.
0 commit comments