614614
615615orjson serializes and deserializes double precision floats with no loss of
616616precision and consistent rounding. The same behavior is observed in rapidjson,
617- simplejson, and json. ujson is inaccurate in both serialization and
618- deserialization, i.e., it modifies the data.
617+ simplejson, and json. ujson 1.35 was inaccurate in both serialization and
618+ deserialization, i.e., it modifies the data, and the recent 2.0 release is
619+ accurate.
619620
620621` orjson.dumps() ` serializes Nan, Infinity, and -Infinity, which are not
621622compliant JSON, as ` null ` :
@@ -831,81 +832,81 @@ format, containing floats and arrays, indented.
831832
832833| Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
833834| ------------| ---------------------------------| -------------------------| ----------------------|
834- | orjson | 0.59 | 1680 | 1 |
835- | ujson | 1.82 | 549.6 | 3.07 |
836- | rapidjson | 2.45 | 408.8 | 4.12 |
837- | simplejson | 3.23 | 309.7 | 5.44 |
838- | json | 3.22 | 310 .1 | 5.43 |
835+ | orjson | 0.66 | 1524.6 | 1 |
836+ | ujson | 2.04 | 489.4 | 3.11 |
837+ | rapidjson | 2.44 | 410.2 | 3.71 |
838+ | simplejson | 3.22 | 309.7 | 4.91 |
839+ | json | 3.24 | 309 .1 | 4.93 |
839840
840841#### twitter.json deserialization
841842
842843| Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
843844| ------------| ---------------------------------| -------------------------| ----------------------|
844- | orjson | 2.67 | 374.3 | 1 |
845- | ujson | 2.87 | 348.7 | 1.07 |
846- | rapidjson | 3.73 | 268.4 | 1.39 |
847- | simplejson | 3.51 | 285.9 | 1.32 |
848- | json | 3.85 | 260.4 | 1.44 |
845+ | orjson | 2.46 | 406.9 | 1 |
846+ | ujson | 2.9 | 344.6 | 1.18 |
847+ | rapidjson | 3.74 | 267.3 | 1.52 |
848+ | simplejson | 3.64 | 276.5 | 1.48 |
849+ | json | 4.21 | 238.9 | 1.71 |
849850
850851#### github.json serialization
851852
852853| Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
853854| ------------| ---------------------------------| -------------------------| ----------------------|
854- | orjson | 0.07 | 14839.8 | 1 |
855- | ujson | 0.18 | 5596.8 | 2.65 |
856- | rapidjson | 0.27 | 3749.5 | 3.96 |
857- | simplejson | 0.44 | 2296.9 | 6.46 |
858- | json | 0.36 | 2740.7 | 5.42 |
855+ | orjson | 0.07 | 13244.4 | 1 |
856+ | ujson | 0.2 | 4869 | 2.73 |
857+ | rapidjson | 0.27 | 3768.1 | 3.54 |
858+ | simplejson | 0.44 | 2290.3 | 5.83 |
859+ | json | 0.35 | 2821.8 | 4.73 |
859860
860861#### github.json deserialization
861862
862863| Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
863864| ------------| ---------------------------------| -------------------------| ----------------------|
864- | orjson | 0.22 | 4449.3 | 1 |
865- | ujson | 0.28 | 3530.5 | 1.26 |
866- | rapidjson | 0.31 | 3186.7 | 1.4 |
867- | simplejson | 0.29 | 3489.7 | 1.27 |
868- | json | 0.33 | 3070.2 | 1.45 |
865+ | orjson | 0.21 | 4811.7 | 1 |
866+ | ujson | 0.28 | 3540.1 | 1.36 |
867+ | rapidjson | 0.31 | 3207.8 | 1.5 |
868+ | simplejson | 0.29 | 3443.9 | 1.4 |
869+ | json | 0.33 | 3046.7 | 1.59 |
869870
870871#### citm_catalog.json serialization
871872
872873| Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
873874| ------------| ---------------------------------| -------------------------| ----------------------|
874- | orjson | 1.02 | 985.4 | 1 |
875- | ujson | 3.07 | 325 | 3.03 |
876- | rapidjson | 3.54 | 282.8 | 3.48 |
877- | simplejson | 10.82 | 92 | 10.66 |
878- | json | 6.77 | 147.4 | 6.67 |
875+ | orjson | 1.02 | 978.7 | 1 |
876+ | ujson | 3.48 | 287.7 | 3.4 |
877+ | rapidjson | 3.48 | 287.3 | 3.4 |
878+ | simplejson | 10.85 | 91.3 | 10.62 |
879+ | json | 6.79 | 147.4 | 6.64 |
879880
880881#### citm_catalog.json deserialization
881882
882883| Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
883884| ------------| ---------------------------------| -------------------------| ----------------------|
884- | orjson | 5.07 | 194.2 | 1 |
885- | ujson | 6.22 | 160.7 | 1.23 |
886- | rapidjson | 7.49 | 133.6 | 1.48 |
887- | simplejson | 7.46 | 133.9 | 1.47 |
888- | json | 8.02 | 124.5 | 1.58 |
885+ | orjson | 4.38 | 228.3 | 1 |
886+ | ujson | 5.58 | 179.2 | 1.27 |
887+ | rapidjson | 7.52 | 132.2 | 1.72 |
888+ | simplejson | 7.4 | 135.2 | 1.69 |
889+ | json | 7.88 | 126.9 | 1.8 |
889890
890891#### canada.json serialization
891892
892893| Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
893894| ------------| ---------------------------------| -------------------------| ----------------------|
894- | orjson | 4.8 | 202 | 1 |
895- | ujson | | | |
896- | rapidjson | 63.97 | 15.6 | 13.33 |
897- | simplejson | 82.38 | 12.1 | 17.17 |
898- | json | 64.96 | 15.4 | 13.54 |
895+ | orjson | 4.69 | 209.7 | 1 |
896+ | ujson | 20.03 | 49.9 | 4.27 |
897+ | rapidjson | 61.8 | 16.2 | 13.17 |
898+ | simplejson | 79.63 | 12.6 | 16.96 |
899+ | json | 62.73 | 15.9 | 13.36 |
899900
900901#### canada.json deserialization
901902
902903| Library | Median latency (milliseconds) | Operations per second | Relative (latency) |
903904| ------------| ---------------------------------| -------------------------| ----------------------|
904- | orjson | 16.25 | 61 .5 | 1 |
905- | ujson | | | |
906- | rapidjson | 38.02 | 26.3 | 2.34 |
907- | simplejson | 37.2 | 26.9 | 2.29 |
908- | json | 37.78 | 27.2 | 2.33 |
905+ | orjson | 10.14 | 98 .5 | 1 |
906+ | ujson | 15.58 | 64.4 | 1.54 |
907+ | rapidjson | 37.3 | 26.8 | 3.68 |
908+ | simplejson | 36.4 | 27.5 | 3.59 |
909+ | json | 37.24 | 27.2 | 3.67 |
909910
910911If a row is blank, the library did not serialize and deserialize the fixture without
911912modifying it, e.g., returning different values for floating point numbers.
@@ -924,45 +925,45 @@ calling `loads()` on the fixture.
924925| Library | import, read() RSS (MiB) | loads() increase in RSS (MiB) |
925926| ------------| ----------------------------| ---------------------------------|
926927| orjson | 13.6 | 2.5 |
927- | ujson | 13.2 | 4.2 |
928- | rapidjson | 14.8 | 6.5 |
929- | simplejson | 13.3 | 2.5 |
930- | json | 12.9 | 2.3 |
928+ | ujson | 14.1 | 4.1 |
929+ | rapidjson | 14.7 | 6.4 |
930+ | simplejson | 13.5 | 2.5 |
931+ | json | 13 | 2.3 |
931932
932933#### github.json
933934
934935| Library | import, read() RSS (MiB) | loads() increase in RSS (MiB) |
935936| ------------| ----------------------------| ---------------------------------|
936- | orjson | 13 | 0.3 |
937- | ujson | 12.5 | 0.6 |
938- | rapidjson | 14.3 | 0.7 |
937+ | orjson | 13.1 | 0.3 |
938+ | ujson | 13.7 | 0.3 |
939+ | rapidjson | 14 | 0.7 |
939940| simplejson | 12.7 | 0.3 |
940- | json | 12.3 | 0.3 |
941+ | json | 12.3 | 0.1 |
941942
942943#### citm_catalog.json
943944
944945| Library | import, read() RSS (MiB) | loads() increase in RSS (MiB) |
945946| ------------| ----------------------------| ---------------------------------|
946947| orjson | 15 | 7.7 |
947- | ujson | 14.5 | 11 |
948- | rapidjson | 15.8 | 36 |
948+ | ujson | 15.4 | 11.1 |
949+ | rapidjson | 15.8 | 29.4 |
949950| simplejson | 14.5 | 30.7 |
950- | json | 14.1 | 27.1 |
951+ | json | 14.2 | 27.2 |
951952
952953#### canada.json
953954
954- | Library | import, read() RSS (MiB) | loads() increase in RSS (MiB) |
955+ | Library | import, read() RSS (MiB) | loads() increase in RSS (MiB) |
955956| ------------| ----------------------------| ---------------------------------|
956- | orjson | 17.3 | 15.7 |
957- | ujson | | |
958- | rapidjson | 18.2 | 17.9 |
959- | simplejson | 17.1 | 19.6 |
960- | json | 16.6 | 19.4 |
957+ | orjson | 17.3 | 15.7 |
958+ | ujson | 17.7 | 17.4 |
959+ | rapidjson | 18.3 | 17.9 |
960+ | simplejson | 17.1 | 19.6 |
961+ | json | 16.8 | 19.4 |
961962
962963### Reproducing
963964
964965The above was measured using Python 3.8.2 on Linux (x86_64) with
965- orjson 2.6.1 , ujson 1.35 , python-rapidson 0.9.1, and simplejson 3.17.0.
966+ orjson 2.6.4 , ujson 2.0.3 , python-rapidson 0.9.1, and simplejson 3.17.0.
966967
967968The latency results can be reproduced using the ` pybench ` and ` graph `
968969scripts. The memory results can be reproduced using the ` pymem ` script.
0 commit comments