python-rapidjson 1.17__tar.gz → 1.19__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. {python-rapidjson-1.17 → python-rapidjson-1.19}/CHANGES.rst +16 -0
  2. {python-rapidjson-1.17 → python-rapidjson-1.19}/LICENSE +1 -0
  3. {python-rapidjson-1.17 → python-rapidjson-1.19}/MANIFEST.in +1 -0
  4. {python-rapidjson-1.17 → python-rapidjson-1.19}/PKG-INFO +17 -1
  5. {python-rapidjson-1.17 → python-rapidjson-1.19}/benchmarks/conftest.py +30 -2
  6. {python-rapidjson-1.17 → python-rapidjson-1.19}/benchmarks/tablize.py +37 -25
  7. python-rapidjson-1.19/docs/benchmarks-tables.rst +123 -0
  8. {python-rapidjson-1.17 → python-rapidjson-1.19}/docs/changes.rst +16 -0
  9. {python-rapidjson-1.17 → python-rapidjson-1.19}/docs/decoder.rst +3 -3
  10. {python-rapidjson-1.17 → python-rapidjson-1.19}/python_rapidjson.egg-info/PKG-INFO +17 -1
  11. {python-rapidjson-1.17 → python-rapidjson-1.19}/python_rapidjson.egg-info/SOURCES.txt +2 -1
  12. python-rapidjson-1.19/python_rapidjson.egg-info/top_level.txt +2 -0
  13. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson.cpp +10 -7
  14. {python-rapidjson-1.17 → python-rapidjson-1.19}/requirements-test.txt +1 -0
  15. {python-rapidjson-1.17 → python-rapidjson-1.19}/requirements.txt +2 -3
  16. {python-rapidjson-1.17 → python-rapidjson-1.19}/setup.py +4 -0
  17. {python-rapidjson-1.17 → python-rapidjson-1.19}/tests/test_float.py +13 -1
  18. python-rapidjson-1.19/typings/rapidjson/__init__.pyi +232 -0
  19. python-rapidjson-1.19/version.txt +1 -0
  20. python-rapidjson-1.17/docs/benchmarks-tables.rst +0 -121
  21. python-rapidjson-1.17/python_rapidjson.egg-info/top_level.txt +0 -1
  22. python-rapidjson-1.17/version.txt +0 -1
  23. {python-rapidjson-1.17 → python-rapidjson-1.19}/.dir-locals.el +0 -0
  24. {python-rapidjson-1.17 → python-rapidjson-1.19}/README.rst +0 -0
  25. {python-rapidjson-1.17 → python-rapidjson-1.19}/benchmarks/test_benchmark.py +0 -0
  26. {python-rapidjson-1.17 → python-rapidjson-1.19}/docs/Makefile +0 -0
  27. {python-rapidjson-1.17 → python-rapidjson-1.19}/docs/api.rst +0 -0
  28. {python-rapidjson-1.17 → python-rapidjson-1.19}/docs/benchmarks.rst +0 -0
  29. {python-rapidjson-1.17 → python-rapidjson-1.19}/docs/conf.py +0 -0
  30. {python-rapidjson-1.17 → python-rapidjson-1.19}/docs/dump.rst +0 -0
  31. {python-rapidjson-1.17 → python-rapidjson-1.19}/docs/dumps.rst +0 -0
  32. {python-rapidjson-1.17 → python-rapidjson-1.19}/docs/encoder.rst +0 -0
  33. {python-rapidjson-1.17 → python-rapidjson-1.19}/docs/index.rst +0 -0
  34. {python-rapidjson-1.17 → python-rapidjson-1.19}/docs/load.rst +0 -0
  35. {python-rapidjson-1.17 → python-rapidjson-1.19}/docs/loads.rst +0 -0
  36. {python-rapidjson-1.17 → python-rapidjson-1.19}/docs/quickstart.rst +0 -0
  37. {python-rapidjson-1.17 → python-rapidjson-1.19}/docs/rawjson.rst +0 -0
  38. {python-rapidjson-1.17 → python-rapidjson-1.19}/docs/validator.rst +0 -0
  39. {python-rapidjson-1.17 → python-rapidjson-1.19}/python_rapidjson.egg-info/dependency_links.txt +0 -0
  40. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/allocators.h +0 -0
  41. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/cursorstreamwrapper.h +0 -0
  42. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/document.h +0 -0
  43. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/encodedstream.h +0 -0
  44. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/encodings.h +0 -0
  45. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/error/en.h +0 -0
  46. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/error/error.h +0 -0
  47. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/filereadstream.h +0 -0
  48. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/filewritestream.h +0 -0
  49. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/fwd.h +0 -0
  50. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/internal/biginteger.h +0 -0
  51. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/internal/clzll.h +0 -0
  52. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/internal/diyfp.h +0 -0
  53. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/internal/dtoa.h +0 -0
  54. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/internal/ieee754.h +0 -0
  55. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/internal/itoa.h +0 -0
  56. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/internal/meta.h +0 -0
  57. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/internal/pow10.h +0 -0
  58. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/internal/regex.h +0 -0
  59. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/internal/stack.h +0 -0
  60. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/internal/strfunc.h +0 -0
  61. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/internal/strtod.h +0 -0
  62. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/internal/swap.h +0 -0
  63. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/istreamwrapper.h +0 -0
  64. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/memorybuffer.h +0 -0
  65. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/memorystream.h +0 -0
  66. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/msinttypes/inttypes.h +0 -0
  67. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/msinttypes/stdint.h +0 -0
  68. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/ostreamwrapper.h +0 -0
  69. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/pointer.h +0 -0
  70. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/prettywriter.h +0 -0
  71. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/rapidjson.h +0 -0
  72. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/reader.h +0 -0
  73. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/schema.h +0 -0
  74. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/stream.h +0 -0
  75. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/stringbuffer.h +0 -0
  76. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/uri.h +0 -0
  77. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/include/rapidjson/writer.h +0 -0
  78. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/license.txt +0 -0
  79. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson/readme.md +0 -0
  80. {python-rapidjson-1.17 → python-rapidjson-1.19}/rapidjson_exact_version.txt +0 -0
  81. {python-rapidjson-1.17 → python-rapidjson-1.19}/setup.cfg +0 -0
  82. {python-rapidjson-1.17 → python-rapidjson-1.19}/tests/conftest.py +0 -0
  83. {python-rapidjson-1.17 → python-rapidjson-1.19}/tests/test_base_types.py +0 -0
  84. {python-rapidjson-1.17 → python-rapidjson-1.19}/tests/test_circular.py +0 -0
  85. {python-rapidjson-1.17 → python-rapidjson-1.19}/tests/test_dict_subclass.py +0 -0
  86. {python-rapidjson-1.17 → python-rapidjson-1.19}/tests/test_enum.py +0 -0
  87. {python-rapidjson-1.17 → python-rapidjson-1.19}/tests/test_memory_leaks.py +0 -0
  88. {python-rapidjson-1.17 → python-rapidjson-1.19}/tests/test_params.py +0 -0
  89. {python-rapidjson-1.17 → python-rapidjson-1.19}/tests/test_pass1.py +0 -0
  90. {python-rapidjson-1.17 → python-rapidjson-1.19}/tests/test_pass2.py +0 -0
  91. {python-rapidjson-1.17 → python-rapidjson-1.19}/tests/test_pass3.py +0 -0
  92. {python-rapidjson-1.17 → python-rapidjson-1.19}/tests/test_rawjson.py +0 -0
  93. {python-rapidjson-1.17 → python-rapidjson-1.19}/tests/test_refs_count.py +0 -0
  94. {python-rapidjson-1.17 → python-rapidjson-1.19}/tests/test_streams.py +0 -0
  95. {python-rapidjson-1.17 → python-rapidjson-1.19}/tests/test_unicode.py +0 -0
  96. {python-rapidjson-1.17 → python-rapidjson-1.19}/tests/test_validator.py +0 -0
  97. {python-rapidjson-1.17 → python-rapidjson-1.19}/tox.ini +0 -0
@@ -1,6 +1,22 @@
1
1
  Changes
2
2
  -------
3
3
 
4
+ 1.19 (2024-07-28)
5
+ ~~~~~~~~~~~~~~~~~
6
+
7
+ * Properly dump subclasses of ``float`` with custom ``__repr__()`` method ( `issue #213`__)
8
+
9
+ __ https://github.com/python-rapidjson/python-rapidjson/issues/213
10
+
11
+
12
+ 1.18 (2024-06-29)
13
+ ~~~~~~~~~~~~~~~~~
14
+
15
+ * Expose PEP-484 typing stubs, thanks to Rodion Kosianenko and GoodWasHere (`PR #204`__)
16
+
17
+ __ https://github.com/python-rapidjson/python-rapidjson/pull/204
18
+
19
+
4
20
  1.17 (2024-05-18)
5
21
  ~~~~~~~~~~~~~~~~~
6
22
 
@@ -3,6 +3,7 @@ python-rapidjson is licensed under the MIT license.
3
3
  The MIT License (MIT)
4
4
 
5
5
  Copyright (c) 2015, 2016, 2017 Ken Robbins
6
+ Copyright (c) 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 Lele Gaifax
6
7
 
7
8
  Permission is hereby granted, free of charge, to any person obtaining a copy
8
9
  of this software and associated documentation files (the "Software"), to deal
@@ -2,6 +2,7 @@ include .dir-locals.el
2
2
  include LICENSE MANIFEST.in *.cfg *.ini *.py *.rst *.txt
3
3
  include python-rapidjson/*.cpp python-rapidjson/*.h
4
4
  include benchmarks/*.py tests/*.py
5
+ include typings/*.pyi
5
6
 
6
7
  exclude .github .gitmodules
7
8
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-rapidjson
3
- Version: 1.17
3
+ Version: 1.19
4
4
  Summary: Python wrapper around rapidjson
5
5
  Home-page: https://github.com/python-rapidjson/python-rapidjson
6
6
  Author: Ken Robbins
@@ -155,6 +155,22 @@ __ https://python-rapidjson.readthedocs.io/en/latest/quickstart.html#incompatibi
155
155
  Changes
156
156
  -------
157
157
 
158
+ 1.19 (2024-07-28)
159
+ ~~~~~~~~~~~~~~~~~
160
+
161
+ * Properly dump subclasses of ``float`` with custom ``__repr__()`` method ( `issue #213`__)
162
+
163
+ __ https://github.com/python-rapidjson/python-rapidjson/issues/213
164
+
165
+
166
+ 1.18 (2024-06-29)
167
+ ~~~~~~~~~~~~~~~~~
168
+
169
+ * Expose PEP-484 typing stubs, thanks to Rodion Kosianenko and GoodWasHere (`PR #204`__)
170
+
171
+ __ https://github.com/python-rapidjson/python-rapidjson/pull/204
172
+
173
+
158
174
  1.17 (2024-05-18)
159
175
  ~~~~~~~~~~~~~~~~~
160
176
 
@@ -2,7 +2,7 @@
2
2
  # :Project: python-rapidjson -- Benchmarks specific pytest configuration
3
3
  # :Author: Lele Gaifax <lele@metapensiero.it>
4
4
  # :License: MIT License
5
- # :Copyright: © 2016, 2017, 2018, 2020 Lele Gaifax
5
+ # :Copyright: © 2016, 2017, 2018, 2020, 2024 Lele Gaifax
6
6
  #
7
7
 
8
8
  from collections import namedtuple
@@ -56,6 +56,32 @@ contenders.append(Contender('rapidjson_nn_c',
56
56
  rj.Encoder(number_mode=rj.NM_NATIVE),
57
57
  rj.Decoder(number_mode=rj.NM_NATIVE)))
58
58
 
59
+
60
+
61
+ class DecoderPython(rj.Decoder):
62
+ def end_array(self, a):
63
+ return a
64
+
65
+ def start_object(self):
66
+ return {}
67
+
68
+ def end_object(self, d):
69
+ return d
70
+
71
+ def string(self, s):
72
+ return s
73
+
74
+
75
+ class EncoderPython(rj.Encoder):
76
+ def default(self, obj):
77
+ return repr(obj)
78
+
79
+
80
+ contenders.append(Contender('rapidjson_p',
81
+ EncoderPython(),
82
+ DecoderPython()))
83
+
84
+
59
85
  numbers_contenders = [
60
86
  Contender('Wide numbers', rj.dumps, rj.loads),
61
87
  Contender('Native numbers',
@@ -147,7 +173,9 @@ def pytest_generate_tests(metafunc):
147
173
  if metafunc.config.option.compare_other_engines:
148
174
  metafunc.parametrize('contender', contenders, ids=attrgetter('name'))
149
175
  else:
150
- metafunc.parametrize('contender', contenders[:1], ids=attrgetter('name'))
176
+ metafunc.parametrize('contender', [c for c in contenders
177
+ if c.name.startswith('rapidjson')],
178
+ ids=attrgetter('name'))
151
179
 
152
180
  if 'datetimes_loads_contender' in metafunc.fixturenames:
153
181
  metafunc.parametrize('datetimes_loads_contender',
@@ -70,7 +70,7 @@ class Comparison:
70
70
  cells = ['=' * (width+2) for width in widths]
71
71
  headseprow = '+' + '+'.join(cells) + '+'
72
72
 
73
- cells = [' {:^%d} ' % width for width in widths]
73
+ cells = [f' {{:^{width}}} ' for width in widths]
74
74
  rowfmt = '|' + '|'.join(cells) + '|'
75
75
 
76
76
  print(seprow)
@@ -95,6 +95,7 @@ def dumps_and_loads(benchmarks):
95
95
  'rapidjson_c',
96
96
  'rapidjson_nn_f',
97
97
  'rapidjson_nn_c',
98
+ 'rapidjson_p',
98
99
  'simdjson',
99
100
  'orjson',
100
101
  'ujson',
@@ -104,15 +105,17 @@ def dumps_and_loads(benchmarks):
104
105
  r'``Encoder()``\ [2]_',
105
106
  r'``dumps(n)``\ [3]_',
106
107
  r'``Encoder(n)``\ [4]_',
107
- r'simdjson\ [5]_',
108
- r'orjson\ [6]_',
109
- r'ujson\ [7]_',
110
- r'simplejson\ [8]_',
111
- r'stdlib\ [9]_')
112
- d_headers = (r'``loads()``\ [10]_',
113
- r'``Decoder()``\ [11]_',
114
- r'``loads(n)``\ [12]_',
115
- r'``Decoder(n)``\ [13]_',
108
+ r'``PyEncoder()``\ [5]_',
109
+ r'simdjson\ [6]_',
110
+ r'orjson\ [7]_',
111
+ r'ujson\ [8]_',
112
+ r'simplejson\ [9]_',
113
+ r'stdlib\ [10]_')
114
+ d_headers = (r'``loads()``\ [11]_',
115
+ r'``Decoder()``\ [12]_',
116
+ r'``loads(n)``\ [13]_',
117
+ r'``Decoder(n)``\ [14]_',
118
+ r'``PyDecoder()``\ [15]_',
116
119
  r'simdjson',
117
120
  r'orjson',
118
121
  r'ujson',
@@ -121,20 +124,29 @@ def dumps_and_loads(benchmarks):
121
124
 
122
125
  assert len(contenders) == len(s_headers) == len(d_headers)
123
126
 
127
+ from csimdjson import VERSION as simdjv
128
+ from orjson import __version__ as orjv
129
+ from simplejson import __version__ as sjv
130
+ from ujson import __version__ as ujv
131
+
132
+ pyv = '%d.%d.%d' % sys.version_info[:3]
133
+
124
134
  footnotes = [
125
135
  '.. [1] ``rapidjson.dumps()``',
126
136
  '.. [2] ``rapidjson.Encoder()``',
127
137
  '.. [3] ``rapidjson.dumps(number_mode=NM_NATIVE)``',
128
138
  '.. [4] ``rapidjson.Encoder(number_mode=NM_NATIVE)``',
129
- '.. [5] `simdjson 6.0.2 <https://pypi.org/project/pysimdjson/6.0.2/>`__',
130
- '.. [6] `orjson 3.10.1 <https://pypi.org/project/orjson/3.10.1/>`__',
131
- '.. [7] `ujson 5.9.0 <https://pypi.org/project/ujson/5.9.0/>`__',
132
- '.. [8] `simplejson 3.19.2 <https://pypi.org/pypi/simplejson/3.19.2>`__',
133
- '.. [9] Python %d.%d.%d standard library ``json``' % sys.version_info[:3],
134
- '.. [10] ``rapidjson.loads()``',
135
- '.. [11] ``rapidjson.Decoder()``',
136
- '.. [12] ``rapidjson.loads(number_mode=NM_NATIVE)``',
137
- '.. [13] ``rapidjson.Decoder(number_mode=NM_NATIVE)``']
139
+ '.. [5] ``rapidjson.Encoder()`` subclassed in Python with *no-op* hook methods',
140
+ f'.. [6] `simdjson {simdjv} <https://pypi.org/project/pysimdjson/>`__',
141
+ f'.. [7] `orjson {orjv} <https://pypi.org/project/orjson/{orjv}/>`__',
142
+ f'.. [8] `ujson {ujv} <https://pypi.org/project/ujson/{ujv}/>`__',
143
+ f'.. [9] `simplejson {sjv} <https://pypi.org/pypi/simplejson/{sjv}>`__',
144
+ f'.. [10] Python {pyv} standard library ``json``',
145
+ '.. [11] ``rapidjson.loads()``',
146
+ '.. [12] ``rapidjson.Decoder()``',
147
+ '.. [13] ``rapidjson.loads(number_mode=NM_NATIVE)``',
148
+ '.. [14] ``rapidjson.Decoder(number_mode=NM_NATIVE)``',
149
+ '.. [15] ``rapidjson.Decoder() subclassed in Python with *no-op* hook methods``']
138
150
 
139
151
  comparison = Comparison(contenders, benchmarks)
140
152
 
@@ -157,17 +169,17 @@ def ascii_vs_utf8(benchmarks):
157
169
  ('ujson', 'uj'),
158
170
  ('simplejson', 'sj'),
159
171
  ('stdlib json', 'json'))
160
- contenders = ['%s %s' % (e[0], k) for e in engines for k in ('ascii', 'utf8')]
161
- i = 14
172
+ contenders = [f'{e[0]} {k}' for e in engines for k in ('ascii', 'utf8')]
173
+ i = 15
162
174
  s_headers = []
163
175
  footnotes = []
164
176
  for e in engines:
165
177
  i += 1
166
- s_headers.append(r'``%s ascii``\ [%d]_' % (e[1], i))
167
- footnotes.append('.. [%d] ``%s.dumps(ensure_ascii=True)``' % (i, e[0]))
178
+ s_headers.append(rf'``{e[1]} ascii``\ [{i}]_')
179
+ footnotes.append(f'.. [{i}] ``{e[0]}.dumps(ensure_ascii=True)``')
168
180
  i += 1
169
- s_headers.append(r'``%s utf8``\ [%d]_' % (e[1], i))
170
- footnotes.append('.. [%d] ``%s.dumps(ensure_ascii=False)``' % (i, e[0]))
181
+ s_headers.append(rf'``{e[1]} utf8``\ [{i}]_')
182
+ footnotes.append(f'.. [{i}] ``{e[0]}.dumps(ensure_ascii=False)``')
171
183
 
172
184
  comparison = Comparison(contenders, benchmarks)
173
185
 
@@ -0,0 +1,123 @@
1
+
2
+ Serialization
3
+ ~~~~~~~~~~~~~
4
+
5
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
6
+ | serialize | ``dumps()``\ [1]_ | ``Encoder()``\ [2]_ | ``dumps(n)``\ [3]_ | ``Encoder(n)``\ [4]_ | ``PyEncoder()``\ [5]_ | simdjson\ [6]_ | orjson\ [7]_ | ujson\ [8]_ | simplejson\ [9]_ | stdlib\ [10]_ |
7
+ +=======================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+
8
+ | 100 arrays dict | 1.00 | 1.00 | 0.73 | 0.73 | 0.99 | 2.21 | **0.17** | 0.85 | 5.93 | 2.31 |
9
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
10
+ | 100 dicts array | 1.00 | 0.99 | 0.77 | 0.74 | 1.01 | 2.27 | **0.22** | 0.84 | 6.82 | 2.27 |
11
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
12
+ | 256 Trues array | 1.00 | 1.01 | 1.18 | 1.00 | 1.07 | 2.62 | **0.36** | 1.56 | 2.95 | 2.60 |
13
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
14
+ | 256 ascii array | 1.00 | 1.00 | 1.01 | 1.00 | 1.00 | 0.90 | **0.09** | 0.47 | 1.05 | 0.90 |
15
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
16
+ | 256 doubles array | 1.00 | 1.00 | 1.00 | 1.00 | 1.00 | 0.91 | **0.04** | 0.22 | 0.95 | 0.92 |
17
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
18
+ | 256 unicode array | 1.00 | 0.80 | 0.79 | 0.82 | 0.80 | 0.68 | **0.02** | 0.52 | 0.66 | 0.68 |
19
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
20
+ | apache.json | 1.00 | 1.00 | 1.00 | 1.00 | 1.01 | 1.70 | **0.19** | 1.02 | 3.29 | 1.68 |
21
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
22
+ | canada.json | 1.00 | 1.00 | 0.98 | 0.99 | 1.00 | 1.04 | **0.06** | 0.27 | 1.81 | 1.05 |
23
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
24
+ | complex object | 1.00 | 1.00 | 0.89 | 0.88 | 1.00 | 1.55 | **0.17** | 0.66 | 2.68 | 1.54 |
25
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
26
+ | composite object | 1.00 | 0.99 | 0.68 | 0.64 | 0.98 | 1.70 | **0.21** | 0.83 | 2.48 | 1.72 |
27
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
28
+ | ctm.json | 1.00 | 1.00 | 0.75 | 0.75 | 1.00 | 2.27 | **0.21** | 1.11 | 6.56 | 2.27 |
29
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
30
+ | github.json | 1.00 | 1.00 | 0.97 | 0.96 | 1.00 | 1.38 | **0.16** | 0.86 | 2.10 | 1.39 |
31
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
32
+ | instruments.json | 1.00 | 1.00 | 0.74 | 0.74 | 1.00 | 1.81 | **0.20** | 0.90 | 2.86 | 1.81 |
33
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
34
+ | mesh.json | 1.00 | 1.00 | 0.89 | 0.89 | 1.00 | 0.94 | **0.10** | 0.28 | 1.19 | 0.94 |
35
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
36
+ | truenull.json | 1.00 | 1.02 | 1.06 | 1.03 | 1.03 | 2.13 | **0.28** | 1.76 | 2.12 | 2.21 |
37
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
38
+ | tweet.json | 1.00 | 1.00 | 0.99 | 0.93 | 1.00 | 1.70 | **0.20** | 0.91 | 2.70 | 1.69 |
39
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
40
+ | twitter.json | 1.00 | 1.00 | 0.95 | 0.95 | 1.00 | 1.46 | **0.18** | 0.94 | 2.02 | 1.46 |
41
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
42
+ | overall | 1.00 | 1.00 | 0.80 | 0.80 | 1.00 | 1.85 | **0.14** | 0.68 | 4.63 | 1.92 |
43
+ +-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
44
+
45
+ Deserialization
46
+ ~~~~~~~~~~~~~~~
47
+
48
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
49
+ | deserialize | ``loads()``\ [11]_ | ``Decoder()``\ [12]_ | ``loads(n)``\ [13]_ | ``Decoder(n)``\ [14]_ | ``PyDecoder()``\ [15]_ | simdjson | orjson | ujson | simplejson | stdlib |
50
+ +=======================+========================+========================+========================+========================+========================+========================+========================+========================+========================+========================+
51
+ | 100 arrays dict | 1.00 | 1.01 | 0.98 | 0.93 | 1.59 | 0.86 | **0.56** | 0.85 | 1.20 | 0.94 |
52
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
53
+ | 100 dicts array | 1.00 | 1.00 | 0.87 | 0.86 | 1.58 | 0.62 | **0.36** | 0.69 | 1.35 | 1.00 |
54
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
55
+ | 256 Trues array | 1.00 | 1.02 | 1.08 | 0.98 | 1.14 | 0.93 | **0.42** | 0.96 | 1.53 | 1.37 |
56
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
57
+ | 256 ascii array | 1.00 | 1.00 | 0.99 | 0.99 | 1.50 | 0.50 | **0.33** | 0.85 | 0.86 | 0.77 |
58
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
59
+ | 256 doubles array | 1.00 | 1.00 | 0.26 | 0.26 | 1.01 | 0.21 | **0.16** | 0.61 | 1.08 | 1.03 |
60
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
61
+ | 256 unicode array | 1.00 | 1.00 | 1.00 | 1.00 | 1.07 | 1.12 | **0.41** | 0.82 | 4.06 | 1.45 |
62
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
63
+ | apache.json | 1.00 | 1.00 | 1.01 | 1.01 | 1.57 | 0.68 | **0.44** | 0.79 | 0.84 | 0.82 |
64
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
65
+ | canada.json | 1.00 | 1.00 | 0.33 | 0.33 | 1.12 | 0.29 | **0.25** | 0.54 | 0.97 | 0.96 |
66
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
67
+ | complex object | 1.00 | 1.00 | 0.84 | 0.83 | 1.31 | 0.68 | **0.35** | 0.78 | 1.15 | 0.96 |
68
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
69
+ | composite object | 1.00 | 1.00 | 0.84 | 0.83 | 1.34 | 0.61 | **0.39** | 0.59 | 1.45 | 1.07 |
70
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
71
+ | ctm.json | 1.00 | 0.99 | 0.93 | 0.93 | 1.48 | 0.80 | **0.53** | 1.13 | 1.20 | 0.97 |
72
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
73
+ | github.json | 1.00 | 1.00 | 0.99 | 0.98 | 1.37 | 0.66 | **0.39** | 0.77 | 0.91 | 0.82 |
74
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
75
+ | instruments.json | 1.00 | 1.00 | 0.87 | 0.87 | 1.23 | 0.66 | **0.36** | 0.76 | 1.17 | 0.94 |
76
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
77
+ | mesh.json | 1.00 | 1.00 | 0.52 | 0.51 | 1.04 | 0.43 | **0.33** | 0.66 | 1.48 | 1.04 |
78
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
79
+ | truenull.json | 1.00 | 1.01 | 1.01 | 0.99 | 1.01 | 0.58 | **0.34** | 0.87 | 0.99 | 0.95 |
80
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
81
+ | tweet.json | 1.00 | 1.01 | 0.99 | 0.97 | 1.30 | 0.69 | **0.39** | 0.84 | 1.17 | 0.99 |
82
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
83
+ | twitter.json | 1.00 | 1.00 | 0.97 | 0.97 | 1.25 | 0.68 | **0.39** | 0.85 | 0.99 | 0.89 |
84
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
85
+ | overall | 1.00 | 1.01 | 0.91 | 0.87 | 1.54 | 0.80 | **0.53** | 0.82 | 1.19 | 0.94 |
86
+ +-----------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+------------------------+
87
+
88
+ ASCII vs UTF-8 Serialization
89
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
90
+
91
+ +-------------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
92
+ | serialize | ``rj ascii``\ [16]_ | ``rj utf8``\ [17]_ | ``uj ascii``\ [18]_ | ``uj utf8``\ [19]_ | ``sj ascii``\ [20]_ | ``sj utf8``\ [21]_ | ``json ascii``\ [22]_ | ``json utf8``\ [23]_ |
93
+ +=========================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+=======================+
94
+ | Long ASCII string | 1.00 | 0.43 | **0.24** | 0.29 | 0.60 | 1.24 | 0.57 | 1.00 |
95
+ +-------------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
96
+ | Long Unicode string | 1.00 | 0.57 | 0.64 | **0.47** | 0.72 | 0.62 | 0.76 | 0.48 |
97
+ +-------------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
98
+ | overall | 1.00 | 0.53 | 0.51 | **0.41** | 0.68 | 0.82 | 0.70 | 0.65 |
99
+ +-------------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+-----------------------+
100
+
101
+ .. [1] ``rapidjson.dumps()``
102
+ .. [2] ``rapidjson.Encoder()``
103
+ .. [3] ``rapidjson.dumps(number_mode=NM_NATIVE)``
104
+ .. [4] ``rapidjson.Encoder(number_mode=NM_NATIVE)``
105
+ .. [5] ``rapidjson.Encoder()`` subclassed in Python with *no-op* hook methods
106
+ .. [6] `simdjson 3.6.4 <https://pypi.org/project/pysimdjson/>`__
107
+ .. [7] `orjson 3.10.5 <https://pypi.org/project/orjson/3.10.5/>`__
108
+ .. [8] `ujson 5.10.0 <https://pypi.org/project/ujson/5.10.0/>`__
109
+ .. [9] `simplejson 3.19.2 <https://pypi.org/pypi/simplejson/3.19.2>`__
110
+ .. [10] Python 3.11.9 standard library ``json``
111
+ .. [11] ``rapidjson.loads()``
112
+ .. [12] ``rapidjson.Decoder()``
113
+ .. [13] ``rapidjson.loads(number_mode=NM_NATIVE)``
114
+ .. [14] ``rapidjson.Decoder(number_mode=NM_NATIVE)``
115
+ .. [15] ``rapidjson.Decoder() subclassed in Python with *no-op* hook methods``
116
+ .. [16] ``rapidjson.dumps(ensure_ascii=True)``
117
+ .. [17] ``rapidjson.dumps(ensure_ascii=False)``
118
+ .. [18] ``ujson.dumps(ensure_ascii=True)``
119
+ .. [19] ``ujson.dumps(ensure_ascii=False)``
120
+ .. [20] ``simplejson.dumps(ensure_ascii=True)``
121
+ .. [21] ``simplejson.dumps(ensure_ascii=False)``
122
+ .. [22] ``stdlib json.dumps(ensure_ascii=True)``
123
+ .. [23] ``stdlib json.dumps(ensure_ascii=False)``
@@ -1,6 +1,22 @@
1
1
  Changes
2
2
  -------
3
3
 
4
+ 1.19 (2024-07-28)
5
+ ~~~~~~~~~~~~~~~~~
6
+
7
+ * Properly dump subclasses of ``float`` with custom ``__repr__()`` method ( `issue #213`__)
8
+
9
+ __ https://github.com/python-rapidjson/python-rapidjson/issues/213
10
+
11
+
12
+ 1.18 (2024-06-29)
13
+ ~~~~~~~~~~~~~~~~~
14
+
15
+ * Expose PEP-484 typing stubs, thanks to Rodion Kosianenko and GoodWasHere (`PR #204`__)
16
+
17
+ __ https://github.com/python-rapidjson/python-rapidjson/pull/204
18
+
19
+
4
20
  1.17 (2024-05-18)
5
21
  ~~~~~~~~~~~~~~~~~
6
22
 
@@ -2,7 +2,7 @@
2
2
  .. :Project: python-rapidjson -- Decoder class documentation
3
3
  .. :Author: Lele Gaifax <lele@metapensiero.it>
4
4
  .. :License: MIT License
5
- .. :Copyright: © 2017, 2018, 2020, 2021 Lele Gaifax
5
+ .. :Copyright: © 2017, 2018, 2020, 2021, 2024 Lele Gaifax
6
6
  ..
7
7
 
8
8
  ===============
@@ -77,11 +77,11 @@
77
77
 
78
78
  .. method:: end_array(sequence)
79
79
 
80
- :param sequence: an instance implement the *mutable sequence* protocol
80
+ :param sequence: an instance implementing the *mutable sequence* protocol
81
81
  :returns: a new value
82
82
 
83
83
  This is called, if implemented, when a *JSON array* has been completely parsed, and
84
- can be used replace it with an arbitrary different value:
84
+ can be used to replace it with an arbitrary different value:
85
85
 
86
86
  .. doctest::
87
87
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-rapidjson
3
- Version: 1.17
3
+ Version: 1.19
4
4
  Summary: Python wrapper around rapidjson
5
5
  Home-page: https://github.com/python-rapidjson/python-rapidjson
6
6
  Author: Ken Robbins
@@ -155,6 +155,22 @@ __ https://python-rapidjson.readthedocs.io/en/latest/quickstart.html#incompatibi
155
155
  Changes
156
156
  -------
157
157
 
158
+ 1.19 (2024-07-28)
159
+ ~~~~~~~~~~~~~~~~~
160
+
161
+ * Properly dump subclasses of ``float`` with custom ``__repr__()`` method ( `issue #213`__)
162
+
163
+ __ https://github.com/python-rapidjson/python-rapidjson/issues/213
164
+
165
+
166
+ 1.18 (2024-06-29)
167
+ ~~~~~~~~~~~~~~~~~
168
+
169
+ * Expose PEP-484 typing stubs, thanks to Rodion Kosianenko and GoodWasHere (`PR #204`__)
170
+
171
+ __ https://github.com/python-rapidjson/python-rapidjson/pull/204
172
+
173
+
158
174
  1.17 (2024-05-18)
159
175
  ~~~~~~~~~~~~~~~~~
160
176
 
@@ -89,4 +89,5 @@ tests/test_rawjson.py
89
89
  tests/test_refs_count.py
90
90
  tests/test_streams.py
91
91
  tests/test_unicode.py
92
- tests/test_validator.py
92
+ tests/test_validator.py
93
+ typings/rapidjson/__init__.pyi
@@ -0,0 +1,2 @@
1
+ rapidjson
2
+ rapidjson-stubs
@@ -2443,10 +2443,7 @@ dumps_internal(
2443
2443
  Py_DECREF(intStrObj);
2444
2444
  }
2445
2445
  } else if (PyFloat_Check(object)) {
2446
- double d = PyFloat_AsDouble(object);
2447
- if (d == -1.0 && PyErr_Occurred())
2448
- return false;
2449
-
2446
+ double d = PyFloat_AS_DOUBLE(object);
2450
2447
  if (IS_NAN(d)) {
2451
2448
  if (numberMode & NM_NAN) {
2452
2449
  writer->RawValue("NaN", 3, kNumberType);
@@ -2469,7 +2466,7 @@ dumps_internal(
2469
2466
  // The RJ dtoa() produces "strange" results for particular values, see #101:
2470
2467
  // use Python's repr() to emit a raw value instead of writer->Double(d)
2471
2468
 
2472
- PyObject* dr = PyObject_Repr(object);
2469
+ PyObject* dr = PyFloat_Type.tp_repr(object);
2473
2470
 
2474
2471
  if (dr == NULL)
2475
2472
  return false;
@@ -4032,10 +4029,16 @@ module_exec(PyObject* m)
4032
4029
  ", Lele Gaifax <lele@metapensiero.it>")
4033
4030
  || PyModule_AddStringConstant(m, "__rapidjson_version__",
4034
4031
  RAPIDJSON_VERSION_STRING)
4035
- #ifdef RAPIDJSON_EXACT_VERSION
4036
4032
  || PyModule_AddStringConstant(m, "__rapidjson_exact_version__",
4037
- STRINGIFY(RAPIDJSON_EXACT_VERSION))
4033
+ #ifdef RAPIDJSON_EXACT_VERSION
4034
+ STRINGIFY(RAPIDJSON_EXACT_VERSION)
4035
+ #else
4036
+ // This may happen for several reasons, under CI
4037
+ // test or when the RJ library does not come from
4038
+ // the git submodule
4039
+ "not available"
4038
4040
  #endif
4041
+ )
4039
4042
  )
4040
4043
  return -1;
4041
4044
 
@@ -7,6 +7,7 @@
7
7
  # :Copyright: © 2015, 2017, 2018, 2021, 2022, 2023 Lele Gaifax
8
8
  #
9
9
 
10
+ mypy==1.10.0
10
11
  pytest==7.4.3
11
12
  pytz==2023.3.post1
12
13
  sphinx==7.2.6
@@ -15,8 +15,7 @@ twine==5.0.0
15
15
  # Needed by make benchmarks-*
16
16
  pytest-benchmark==4.0.0
17
17
 
18
- # Keep in sync with benchmarks/tablize.py versions
19
18
  pysimdjson==6.0.2
20
- orjson==3.10.1
19
+ orjson==3.10.5
21
20
  simplejson==3.19.2
22
- ujson==5.9.0
21
+ ujson==5.10.0
@@ -115,5 +115,9 @@ setup(
115
115
  'Programming Language :: Python',
116
116
  ],
117
117
  ext_modules=[Extension('rapidjson', **extension_options)],
118
+ package_dir={"rapidjson-stubs": "typings/rapidjson"},
119
+ packages=["rapidjson-stubs"],
120
+ package_data={"rapidjson-stubs": ["*.pyi"]},
121
+ include_package_data=True,
118
122
  **other_setup_options
119
123
  )
@@ -3,7 +3,7 @@
3
3
  # :Author: John Anderson <sontek@gmail.com>
4
4
  # :License: MIT License
5
5
  # :Copyright: © 2015 John Anderson
6
- # :Copyright: © 2016, 2017, 2020 Lele Gaifax
6
+ # :Copyright: © 2016, 2017, 2020, 2024 Lele Gaifax
7
7
  #
8
8
 
9
9
  from decimal import Decimal
@@ -159,3 +159,15 @@ def test_nan_c():
159
159
  dumped = rj.Encoder(number_mode=rj.NM_DECIMAL|rj.NM_NAN)(d)
160
160
  loaded = rj.Decoder(number_mode=rj.NM_DECIMAL|rj.NM_NAN)(dumped)
161
161
  assert loaded.is_nan()
162
+
163
+
164
+ def test_issue_213():
165
+ class CustomRepr(float):
166
+ def __repr__(self):
167
+ stdrepr = super().__repr__()
168
+ return f'CustomRepr({stdrepr})'
169
+
170
+ f = CustomRepr(123.45)
171
+ dumped = rj.dumps(f)
172
+ loaded = rj.loads(dumped)
173
+ assert loaded == 123.45