1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
Serialization
~~~~~~~~~~~~~
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| serialize | ``dumps()``\ [1]_ | ``Encoder()``\ [2]_ | ``dumps(n)``\ [3]_ | ``Encoder(n)``\ [4]_ | simdjson\ [5]_ | orjson\ [6]_ | ujson\ [7]_ | simplejson\ [8]_ | stdlib\ [9]_ |
+=======================+======================+======================+======================+======================+======================+======================+======================+======================+======================+
| 100 arrays dict | 1.00 | 1.00 | 0.79 | 0.78 | 1.95 | **0.25** | 1.05 | 2.88 | 1.93 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| 100 dicts array | 1.00 | 0.99 | 0.84 | 0.79 | 1.94 | **0.33** | 1.04 | 3.62 | 1.94 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| 256 Trues array | 1.00 | 0.99 | 1.14 | 0.99 | 2.23 | **0.38** | 1.33 | 2.63 | 2.23 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| 256 ascii array | 1.00 | 1.00 | 1.02 | 1.00 | 0.76 | **0.25** | 0.43 | 1.00 | 0.76 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| 256 doubles array | 1.00 | 1.00 | 1.01 | 1.00 | 0.87 | **0.06** | 0.23 | 0.90 | 0.86 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| 256 unicode array | 1.00 | 0.84 | 0.84 | 0.85 | 0.66 | **0.10** | 0.56 | 0.78 | 0.66 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| apache.json | 1.00 | 0.99 | 1.01 | 1.00 | 1.46 | **0.30** | 1.12 | 1.94 | 1.45 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| canada.json | 1.00 | 0.98 | 0.97 | 0.97 | 0.99 | **0.09** | 0.32 | 1.33 | 0.98 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| complex object | 1.00 | 1.00 | 0.93 | 0.92 | 1.51 | **0.26** | 0.76 | 1.87 | 1.50 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| composite object | 1.00 | 1.02 | 0.75 | 0.72 | 1.82 | **0.37** | 0.98 | 2.36 | 1.80 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| ctm.json | 1.00 | 1.00 | 0.79 | 0.79 | 2.00 | **0.31** | 1.21 | 3.12 | 1.93 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| github.json | 1.00 | 1.00 | 0.98 | 0.97 | 1.19 | **0.28** | 0.90 | 1.41 | 1.18 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| instruments.json | 1.00 | 1.00 | 0.86 | 0.86 | 1.62 | **0.33** | 0.99 | 1.77 | 1.60 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| mesh.json | 1.00 | 1.00 | 0.90 | 0.91 | 1.00 | **0.14** | 0.35 | 1.08 | 0.99 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| truenull.json | 1.00 | 0.99 | 1.06 | 1.03 | 1.78 | **0.42** | 1.48 | 1.95 | 1.75 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| tweet.json | 1.00 | 0.99 | 1.00 | 0.96 | 1.51 | **0.33** | 0.92 | 1.96 | 1.50 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| twitter.json | 1.00 | 1.00 | 0.97 | 0.97 | 1.25 | **0.30** | 1.00 | 1.32 | 1.24 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
| overall | 1.00 | 1.00 | 0.83 | 0.83 | 1.69 | **0.21** | 0.86 | 2.44 | 1.67 |
+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+
Deserialization
~~~~~~~~~~~~~~~
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| deserialize | ``loads()``\ [10]_ | ``Decoder()``\ [11]_ | ``loads(n)``\ [12]_ | ``Decoder(n)``\ [13]_ | simdjson | orjson | ujson | simplejson | stdlib |
+=======================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+
| 100 arrays dict | 1.00 | 1.05 | 0.95 | 0.90 | 0.85 | **0.73** | 0.88 | 1.14 | 0.93 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| 100 dicts array | 1.00 | 1.00 | 0.87 | 0.84 | **0.62** | 0.64 | 0.72 | 1.33 | 1.05 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| 256 Trues array | 1.00 | 1.01 | 1.08 | 1.01 | 0.90 | 0.88 | **0.80** | 1.53 | 1.33 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| 256 ascii array | 1.00 | 1.00 | 1.03 | 1.03 | **0.45** | 0.75 | 0.97 | 0.98 | 0.84 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| 256 doubles array | 1.00 | 1.00 | 0.25 | 0.25 | **0.20** | 0.25 | 0.48 | 1.12 | 1.07 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| 256 unicode array | 1.00 | 1.00 | 1.00 | 1.00 | 1.12 | **0.43** | 0.97 | 4.77 | 1.38 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| apache.json | 1.00 | 1.00 | 1.01 | 1.01 | **0.65** | 0.65 | 0.88 | 0.93 | 0.86 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| canada.json | 1.00 | 0.98 | 0.31 | 0.31 | **0.27** | 0.33 | 0.43 | 1.00 | 0.91 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| complex object | 1.00 | 1.01 | 0.88 | 0.87 | 0.66 | **0.57** | 0.84 | 1.18 | 1.01 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| composite object | 1.00 | 1.00 | 0.83 | 0.82 | **0.60** | 0.78 | 0.61 | 1.41 | 1.13 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| ctm.json | 1.00 | 0.92 | 0.83 | 0.84 | 0.65 | **0.62** | 0.92 | 1.15 | 1.03 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| github.json | 1.00 | 1.00 | 0.98 | 0.98 | **0.63** | 0.63 | 0.84 | 0.94 | 0.85 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| instruments.json | 1.00 | 1.00 | 0.86 | 0.86 | 0.64 | **0.55** | 0.72 | 1.10 | 0.92 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| mesh.json | 1.00 | 0.92 | 0.47 | 0.47 | **0.40** | 0.49 | 0.63 | 1.42 | 0.95 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| truenull.json | 1.00 | 1.01 | 1.09 | 1.00 | **0.56** | 0.95 | 0.87 | 1.00 | 0.86 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| tweet.json | 1.00 | 1.00 | 0.98 | 0.97 | 0.67 | **0.64** | 0.86 | 1.21 | 1.08 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| twitter.json | 1.00 | 1.00 | 0.95 | 0.96 | 0.67 | **0.62** | 0.99 | 1.04 | 0.99 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| overall | 1.00 | 1.04 | 0.89 | 0.84 | 0.79 | **0.69** | 0.84 | 1.13 | 0.93 |
+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
ASCII vs UTF-8 Serialization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+-------------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| serialize | ``rj ascii``\ [15]_ | ``rj utf8``\ [16]_ | ``uj ascii``\ [17]_ | ``uj utf8``\ [18]_ | ``sj ascii``\ [19]_ | ``sj utf8``\ [20]_ | ``json ascii``\ [21]_ | ``json utf8``\ [22]_ |
+=========================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+
| Long ASCII string | 1.00 | 0.40 | **0.22** | 0.40 | 0.62 | 0.75 | 0.47 | 1.13 |
+-------------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| Long Unicode string | 1.00 | **0.57** | 0.67 | 0.62 | 0.86 | 0.75 | 0.74 | 0.64 |
+-------------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
| overall | 1.00 | **0.51** | 0.52 | 0.55 | 0.78 | 0.75 | 0.65 | 0.80 |
+-------------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
.. [1] ``rapidjson.dumps()``
.. [2] ``rapidjson.Encoder()``
.. [3] ``rapidjson.dumps(number_mode=NM_NATIVE)``
.. [4] ``rapidjson.Encoder(number_mode=NM_NATIVE)``
.. [5] `simdjson 4.0.0 <https://pypi.org/project/pysimdjson/4.0.0/>`__
.. [6] `orjson 3.5.3 <https://pypi.org/project/orjson/3.5.3/>`__
.. [7] `ujson 4.0.2 <https://pypi.org/project/ujson/4.0.2/>`__
.. [8] `simplejson 3.17.2 <https://pypi.org/pypi/simplejson/3.17.2>`__
.. [9] Python 3.9.2 standard library ``json``
.. [10] ``rapidjson.loads()``
.. [11] ``rapidjson.Decoder()``
.. [12] ``rapidjson.loads(number_mode=NM_NATIVE)``
.. [13] ``rapidjson.Decoder(number_mode=NM_NATIVE)``
.. [15] ``rapidjson.dumps(ensure_ascii=True)``
.. [16] ``rapidjson.dumps(ensure_ascii=False)``
.. [17] ``ujson.dumps(ensure_ascii=True)``
.. [18] ``ujson.dumps(ensure_ascii=False)``
.. [19] ``simplejson.dumps(ensure_ascii=True)``
.. [20] ``simplejson.dumps(ensure_ascii=False)``
.. [21] ``stdlib json.dumps(ensure_ascii=True)``
.. [22] ``stdlib json.dumps(ensure_ascii=False)``
|