diff --git a/Makefile b/Makefile index b003c35..1358303 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ help:: .PHONY: benchmarks benchmarks: build - $(PYTEST) benchmarks/ + PYTHONPATH=. $(PYTEST) benchmarks/ help:: @printf "benchmarks-other\n\trun the benchmarks against other engines\n" @@ -83,12 +83,12 @@ benchmarks-others: PYTEST_OPTIONS = --compare-other-engines benchmarks-others: benchmarks help:: - @printf "benchmarks-table\n\tproduce a reST table out of benchmarks-other results\n" + @printf "benchmarks-tables\n\tproduce a reST table out of benchmarks-other results\n" .PHONY: benchmarks-tables benchmarks-tables: PYTEST_OPTIONS = --compare-other-engines --benchmark-json=comparison.json benchmarks-tables: benchmarks - $(PYTHON) benchmarks/tablize.py | tee docs/benchmarks-tables.rst + PYTHONPATH=. $(PYTHON) benchmarks/tablize.py | tee docs/benchmarks-tables.rst include Makefile.virtualenv include Makefile.release diff --git a/benchmarks/conftest.py b/benchmarks/conftest.py index 514dcc5..02b3713 100644 --- a/benchmarks/conftest.py +++ b/benchmarks/conftest.py @@ -116,21 +116,22 @@ def pytest_addoption(parser): ]) try: - import ujson + import hyperjson except ImportError: pass else: - contenders.append(Contender('ujson', - ujson.dumps, - partial(ujson.loads, precise_float=True))) - string_contenders.extend([ - Contender('ujson utf8', - partial(ujson.dumps, ensure_ascii=False), - ujson.loads), - Contender('ujson ascii', - partial(ujson.dumps, ensure_ascii=True), - ujson.loads), - ]) + contenders.append(Contender('hyperjson', + hyperjson.dumps, + hyperjson.loads)) + +try: + import orjson +except ImportError: + pass +else: + contenders.append(Contender('orjson', + orjson.dumps, + orjson.loads)) def pytest_generate_tests(metafunc): diff --git a/benchmarks/tablize.py b/benchmarks/tablize.py index 2228acc..1435174 100644 --- a/benchmarks/tablize.py +++ b/benchmarks/tablize.py @@ -95,7 +95,8 @@ def dumps_and_loads(benchmarks): 'rapidjson_c', 'rapidjson_nn_f', 'rapidjson_nn_c', - 'ujson', + 'hyperjson', + 'orjson', 'simplejson', 'stdlib json', 'yajl') @@ -103,15 +104,17 @@ def dumps_and_loads(benchmarks): r'``Encoder()``\ [2]_', r'``dumps(n)``\ [3]_', r'``Encoder(n)``\ [4]_', - r'ujson\ [5]_', - r'simplejson\ [6]_', - r'stdlib\ [7]_', - r'yajl\ [8]_') - d_headers = (r'``loads()``\ [9]_', - r'``Decoder()``\ [10]_', - r'``loads(n)``\ [11]_', - r'``Decoder(n)``\ [12]_', - r'ujson', + r'hyperjson\ [5]_', + r'orjson\ [6]_', + r'simplejson\ [7]_', + r'stdlib\ [8]_', + r'yajl\ [9]_') + d_headers = (r'``loads()``\ [10]_', + r'``Decoder()``\ [11]_', + r'``loads(n)``\ [12]_', + r'``Decoder(n)``\ [13]_', + r'hyperjson', + r'orjson', r'simplejson', r'stdlib', r'yajl') @@ -123,14 +126,15 @@ def dumps_and_loads(benchmarks): '.. [2] ``rapidjson.Encoder()``', '.. [3] ``rapidjson.dumps(number_mode=NM_NATIVE)``', '.. [4] ``rapidjson.Encoder(number_mode=NM_NATIVE)``', - '.. [5] `ujson 1.35 `__', - '.. [6] `simplejson 3.16.0 `__', - '.. [7] Python %d.%d.%d standard library ``json``' % sys.version_info[:3], - '.. [8] `yajl 0.3.5 `__', - '.. [9] ``rapidjson.loads()``', - '.. [10] ``rapidjson.Decoder()``', - '.. [11] ``rapidjson.loads(number_mode=NM_NATIVE)``', - '.. [12] ``rapidjson.Decoder(number_mode=NM_NATIVE)``'] + '.. [5] `hyperjson 0.2.4 `__', + '.. [6] `orjson 2.5.0 `__', + '.. [7] `simplejson 3.16.0 `__', + '.. [8] Python %d.%d.%d standard library ``json``' % sys.version_info[:3], + '.. [9] `yajl 0.3.5 `__', + '.. [10] ``rapidjson.loads()``', + '.. [11] ``rapidjson.Decoder()``', + '.. [12] ``rapidjson.loads(number_mode=NM_NATIVE)``', + '.. [13] ``rapidjson.Decoder(number_mode=NM_NATIVE)``'] comparison = Comparison(contenders, benchmarks) @@ -150,11 +154,12 @@ def dumps_and_loads(benchmarks): def ascii_vs_utf8(benchmarks): engines = (('rapidjson', 'rj'), - ('ujson', 'uj'), + # ('hyperjson', 'hj'), # lacks ensure_ascii flag + # ('orjson', 'oj'), # lacks ensure_ascii flag ('simplejson', 'sj'), ('stdlib json', 'json')) contenders = ['%s %s' % (e[0], k) for e in engines for k in ('ascii', 'utf8')] - i = 12 + i = 13 s_headers = [] footnotes = [] for e in engines: diff --git a/docs/benchmarks-tables.rst b/docs/benchmarks-tables.rst index 9e8b0c0..ecdc820 100644 --- a/docs/benchmarks-tables.rst +++ b/docs/benchmarks-tables.rst @@ -2,119 +2,118 @@ Serialization ~~~~~~~~~~~~~ -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| serialize | ``dumps()``\ [1]_ | ``Encoder()``\ [2]_ | ``dumps(n)``\ [3]_ | ``Encoder(n)``\ [4]_ | ujson\ [5]_ | simplejson\ [6]_ | stdlib\ [7]_ | yajl\ [8]_ | -+=======================+======================+======================+======================+======================+======================+======================+======================+======================+ -| 100 arrays dict | 1.00 | 1.00 | **0.65** | 0.66 | 0.81 | 2.95 | 2.01 | 1.26 | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| 100 dicts array | 1.00 | 1.00 | 0.71 | **0.67** | 0.79 | 3.82 | 1.94 | 1.16 | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| 256 Trues array | **1.00** | 1.02 | 1.15 | 1.05 | 1.51 | 2.92 | 2.36 | 1.33 | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| 256 ascii array | 1.00 | 1.00 | 1.02 | 1.01 | **0.50** | 1.14 | 0.87 | 0.91 | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| 256 doubles array | 1.00 | 0.99 | 1.00 | 0.99 | 1.05 | 0.96 | 0.94 | **0.62** | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| 256 unicode array | 1.00 | 0.87 | 0.87 | 0.88 | 0.55 | 0.76 | 0.73 | **0.55** | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| apache.json | **1.00** | 1.00 | 1.00 | 1.01 | 1.03 | 2.27 | 1.69 | 1.67 | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| canada.json | 1.00 | 1.00 | 0.99 | 0.99 | **0.16** | 1.39 | 1.04 | 0.70 | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| complex object | 1.00 | 1.01 | 0.88 | 0.88 | **0.61** | 1.87 | 1.45 | 1.17 | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| composite object | 1.00 | 0.90 | 0.66 | **0.62** | 0.71 | 2.08 | 1.51 | 1.64 | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| ctm.json | 1.00 | 1.00 | **0.68** | 0.69 | 1.09 | 3.45 | 1.96 | 1.41 | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| github.json | 1.00 | 1.01 | 0.96 | 0.96 | **0.86** | 1.63 | 1.36 | 1.49 | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| instruments.json | 1.00 | 1.00 | 0.72 | **0.72** | 0.88 | 1.83 | 1.58 | 1.47 | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| mesh.json | 1.00 | 1.00 | 0.91 | 0.90 | **0.22** | 1.11 | 0.99 | 0.61 | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| truenull.json | **1.00** | 1.01 | 1.03 | 1.00 | 2.20 | 2.19 | 1.91 | 1.35 | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| tweet.json | 1.00 | 1.02 | 1.00 | **0.94** | 0.96 | 2.17 | 1.64 | 1.33 | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| twitter.json | 1.00 | 1.00 | 0.94 | 0.94 | **0.94** | 1.47 | 1.32 | 1.32 | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ -| overall | 1.00 | 1.00 | 0.74 | 0.74 | **0.64** | 2.50 | 1.74 | 1.11 | -+-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| serialize | ``dumps()``\ [1]_ | ``Encoder()``\ [2]_ | ``dumps(n)``\ [3]_ | ``Encoder(n)``\ [4]_ | hyperjson\ [5]_ | orjson\ [6]_ | simplejson\ [7]_ | stdlib\ [8]_ | yajl\ [9]_ | ++=======================+======================+======================+======================+======================+======================+======================+======================+======================+======================+ +| 100 arrays dict | 1.00 | 1.03 | 0.86 | 0.85 | 0.19 | **0.06** | 1.02 | 0.49 | 0.36 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| 100 dicts array | 1.00 | 1.00 | 0.86 | 0.85 | 0.21 | **0.08** | 1.42 | 0.49 | 0.35 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| 256 Trues array | 1.00 | 1.00 | 1.05 | 1.00 | 0.51 | **0.17** | 0.87 | 0.57 | 0.42 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| 256 ascii array | 1.00 | 1.00 | 1.01 | 1.00 | 0.09 | **0.03** | 0.39 | 0.16 | 0.20 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| 256 doubles array | 1.00 | 0.99 | 1.00 | 0.99 | 0.07 | **0.03** | 0.56 | 0.54 | 0.31 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| 256 unicode array | 1.00 | 0.98 | 0.98 | 0.98 | 0.07 | **0.02** | 0.27 | 0.12 | 0.15 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| apache.json | 1.00 | 1.00 | 1.00 | 1.00 | 0.16 | **0.05** | 0.64 | 0.28 | 0.34 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| canada.json | 1.00 | 1.00 | 1.00 | 0.99 | 0.09 | **0.05** | 0.95 | 0.58 | 0.36 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| complex object | 1.00 | 1.00 | 0.94 | 0.94 | 0.31 | **0.07** | 0.76 | 0.45 | 0.45 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| composite object | 1.00 | 1.00 | 0.84 | 0.83 | 0.39 | **0.12** | 0.96 | 0.53 | 0.59 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| ctm.json | 1.00 | 0.99 | 0.84 | 0.85 | 0.31 | **0.09** | 1.18 | 0.46 | 0.39 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| github.json | 1.00 | 1.00 | 0.99 | 0.98 | 0.14 | **0.05** | 0.48 | 0.23 | 0.32 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| instruments.json | 1.00 | 1.00 | 0.89 | 0.89 | 0.31 | **0.07** | 0.57 | 0.40 | 0.43 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| mesh.json | 1.00 | 0.98 | 0.86 | 0.86 | 0.15 | **0.07** | 0.66 | 0.51 | 0.31 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| truenull.json | 1.00 | 1.00 | 1.01 | 1.00 | 3.34 | **0.12** | 0.59 | 0.39 | 0.38 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| tweet.json | 1.00 | 1.00 | 0.99 | 0.98 | 0.35 | **0.07** | 0.63 | 0.32 | 0.33 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| twitter.json | 1.00 | 1.01 | 0.99 | 0.98 | 0.27 | **0.06** | 0.41 | 0.27 | 0.30 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ +| overall | 1.00 | 1.02 | 0.88 | 0.87 | 0.18 | **0.06** | 0.99 | 0.50 | 0.36 | ++-----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+----------------------+ Deserialization ~~~~~~~~~~~~~~~ -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| deserialize | ``loads()``\ [9]_ | ``Decoder()``\ [10]_ | ``loads(n)``\ [11]_ | ``Decoder(n)``\ [12]_ | ujson | simplejson | stdlib | yajl | -+=======================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+ -| 100 arrays dict | 1.00 | 1.00 | 0.90 | **0.89** | 0.97 | 1.25 | 0.98 | 1.14 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| 100 dicts array | 1.00 | 1.00 | 0.85 | **0.83** | 0.89 | 1.59 | 1.22 | 1.16 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| 256 Trues array | 1.00 | **0.99** | 1.12 | 1.01 | 1.12 | 1.84 | 1.59 | 1.92 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| 256 ascii array | 1.00 | 1.00 | 1.01 | 1.00 | 0.97 | 0.96 | **0.83** | 1.10 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| 256 doubles array | 1.00 | 1.00 | 0.23 | **0.22** | 0.56 | 1.09 | 1.06 | 0.47 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| 256 unicode array | 1.00 | 1.00 | **0.99** | 0.99 | 1.05 | 4.08 | 4.02 | 2.46 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| apache.json | 1.00 | 0.99 | 1.01 | 1.00 | 1.00 | **0.94** | 0.96 | 1.15 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| canada.json | 1.00 | 0.99 | **0.30** | 0.31 | 0.72 | 1.00 | 0.95 | 1.09 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| complex object | 1.00 | 0.99 | 0.83 | **0.82** | 1.08 | 1.40 | 1.19 | 1.36 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| composite object | 1.00 | 0.99 | 0.80 | 0.80 | **0.75** | 1.75 | 1.27 | 1.21 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| ctm.json | 1.00 | 0.88 | 0.80 | **0.79** | 0.91 | 1.14 | 1.01 | 1.19 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| github.json | 1.00 | 1.01 | 0.98 | 0.98 | **0.97** | 1.06 | 1.04 | 1.21 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| instruments.json | 1.00 | 1.00 | 0.85 | 0.85 | **0.83** | 1.36 | 1.10 | 1.23 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| mesh.json | 1.00 | 0.95 | **0.46** | 0.46 | 1.04 | 1.48 | 0.97 | 1.19 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| truenull.json | 1.00 | 1.01 | 1.02 | **0.99** | 1.79 | 1.96 | 1.62 | 2.95 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| tweet.json | 1.00 | 1.00 | 0.99 | **0.97** | 1.05 | 1.47 | 1.38 | 1.39 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| twitter.json | 1.00 | 1.00 | **0.97** | 0.97 | 0.99 | 1.10 | 1.03 | 1.25 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| overall | 1.00 | 0.99 | 0.84 | **0.84** | 0.95 | 1.24 | 0.98 | 1.14 | -+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| deserialize | ``loads()``\ [10]_ | ``Decoder()``\ [11]_ | ``loads(n)``\ [12]_ | ``Decoder(n)``\ [13]_ | hyperjson | orjson | simplejson | stdlib | yajl | ++=======================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+ +| 100 arrays dict | 1.00 | 1.07 | 0.92 | 0.93 | 0.48 | **0.26** | 0.72 | 0.36 | 0.56 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| 100 dicts array | 1.00 | 0.98 | 0.93 | 0.91 | 0.37 | **0.19** | 0.74 | 0.34 | 0.51 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| 256 Trues array | 1.00 | 1.00 | 1.02 | 1.00 | 0.31 | **0.13** | 0.42 | 0.28 | 0.60 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| 256 ascii array | 1.00 | 1.00 | 1.00 | 1.00 | 0.16 | **0.14** | 0.25 | 0.17 | 0.52 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| 256 doubles array | 1.00 | 1.00 | 0.75 | 0.71 | **0.13** | 0.17 | 0.53 | 0.39 | 0.27 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| 256 unicode array | 1.00 | 1.00 | 1.02 | 1.01 | 0.10 | **0.10** | 1.12 | 0.97 | 0.93 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| apache.json | 1.00 | 1.00 | 1.01 | 1.01 | 0.35 | **0.20** | 0.33 | 0.27 | 0.57 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| canada.json | 1.00 | 1.00 | 0.70 | 0.70 | **0.20** | 0.22 | 0.55 | 0.41 | 0.58 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| complex object | 1.00 | 1.01 | 0.94 | 0.94 | 0.38 | **0.19** | 0.60 | 0.34 | 0.55 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| composite object | 1.00 | 1.00 | 0.95 | 0.94 | 0.54 | **0.25** | 0.73 | 0.41 | 0.56 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| ctm.json | 1.00 | 0.98 | 0.95 | 0.95 | 0.40 | **0.22** | 0.61 | 0.34 | 0.61 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| github.json | 1.00 | 1.00 | 0.99 | 0.99 | 0.34 | **0.18** | 0.37 | 0.27 | 0.56 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| instruments.json | 1.00 | 1.01 | 0.94 | 0.95 | 0.42 | **0.19** | 0.72 | 0.33 | 0.57 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| mesh.json | 1.00 | 1.00 | 0.85 | 0.82 | 0.21 | **0.19** | 0.64 | 0.29 | 0.48 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| truenull.json | 1.00 | 0.99 | 0.99 | 0.99 | 0.30 | **0.18** | 0.34 | 0.21 | 0.63 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| tweet.json | 1.00 | 1.00 | 1.00 | 0.99 | 0.43 | **0.19** | 0.50 | 0.34 | 0.57 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| twitter.json | 1.00 | 1.00 | 0.99 | 0.99 | 0.41 | **0.19** | 0.43 | 0.28 | 0.55 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| overall | 1.00 | 1.06 | 0.91 | 0.91 | 0.45 | **0.25** | 0.70 | 0.36 | 0.56 | ++-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ ASCII vs UTF-8 Serialization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+-------------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| serialize | ``rj ascii``\ [13]_ | ``rj utf8``\ [14]_ | ``uj ascii``\ [15]_ | ``uj utf8``\ [16]_ | ``sj ascii``\ [17]_ | ``sj utf8``\ [18]_ | ``json ascii``\ [19]_ | ``json utf8``\ [20]_ | -+=========================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+ -| Long ASCII string | 1.00 | 0.51 | **0.25** | 0.47 | 0.71 | 1.47 | 0.58 | 1.14 | -+-------------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| Long Unicode string | 1.00 | 0.59 | 0.66 | 0.56 | 0.81 | 0.67 | 0.78 | **0.53** | -+-------------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ -| overall | 1.00 | 0.57 | 0.54 | **0.53** | 0.78 | 0.91 | 0.72 | 0.71 | -+-------------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ ++-------------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| serialize | ``rj ascii``\ [14]_ | ``rj utf8``\ [15]_ | ``sj ascii``\ [16]_ | ``sj utf8``\ [17]_ | ``json ascii``\ [18]_ | ``json utf8``\ [19]_ | ++=========================+=======================+=======================+=======================+=======================+=======================+=======================+ +| Long ASCII string | 1.00 | 0.70 | 0.30 | 0.19 | **0.09** | 0.13 | ++-------------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| Long Unicode string | 1.00 | 0.54 | 0.24 | 0.08 | 0.10 | **0.06** | ++-------------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ +| overall | 1.00 | 0.59 | 0.26 | 0.11 | 0.10 | **0.08** | ++-------------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+ .. [1] ``rapidjson.dumps()`` .. [2] ``rapidjson.Encoder()`` .. [3] ``rapidjson.dumps(number_mode=NM_NATIVE)`` .. [4] ``rapidjson.Encoder(number_mode=NM_NATIVE)`` -.. [5] `ujson 1.35 `__ -.. [6] `simplejson 3.16.0 `__ -.. [7] Python 3.7.0 standard library ``json`` -.. [8] `yajl 0.3.5 `__ -.. [9] ``rapidjson.loads()`` -.. [10] ``rapidjson.Decoder()`` -.. [11] ``rapidjson.loads(number_mode=NM_NATIVE)`` -.. [12] ``rapidjson.Decoder(number_mode=NM_NATIVE)`` -.. [13] ``rapidjson.dumps(ensure_ascii=True)`` -.. [14] ``rapidjson.dumps(ensure_ascii=False)`` -.. [15] ``ujson.dumps(ensure_ascii=True)`` -.. [16] ``ujson.dumps(ensure_ascii=False)`` -.. [17] ``simplejson.dumps(ensure_ascii=True)`` -.. [18] ``simplejson.dumps(ensure_ascii=False)`` -.. [19] ``stdlib json.dumps(ensure_ascii=True)`` -.. [20] ``stdlib json.dumps(ensure_ascii=False)`` +.. [5] `hyperjson 0.2.4 `__ +.. [6] `orjson 2.5.0 `__ +.. [7] `simplejson 3.16.0 `__ +.. [8] Python 3.7.6 standard library ``json`` +.. [9] `yajl 0.3.5 `__ +.. [10] ``rapidjson.loads()`` +.. [11] ``rapidjson.Decoder()`` +.. [12] ``rapidjson.loads(number_mode=NM_NATIVE)`` +.. [13] ``rapidjson.Decoder(number_mode=NM_NATIVE)`` +.. [14] ``rapidjson.dumps(ensure_ascii=True)`` +.. [15] ``rapidjson.dumps(ensure_ascii=False)`` +.. [16] ``simplejson.dumps(ensure_ascii=True)`` +.. [17] ``simplejson.dumps(ensure_ascii=False)`` +.. [18] ``stdlib json.dumps(ensure_ascii=True)`` +.. [19] ``stdlib json.dumps(ensure_ascii=False)`` diff --git a/requirements.txt b/requirements.txt index b9aba0f..78ff4f5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,6 +16,7 @@ twine==1.13.0 pytest-benchmark==3.2.2 # Keep in sync with benchmarks/tablize.py versions +hyperjson==0.2.4 +orjson==2.5.0 simplejson==3.16.0 -ujson==1.35 yajl==0.3.5