json2xml 5.2.1__tar.gz → 5.4.0__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 (43) hide show
  1. {json2xml-5.2.1 → json2xml-5.4.0}/HISTORY.rst +46 -0
  2. {json2xml-5.2.1 → json2xml-5.4.0}/PKG-INFO +130 -14
  3. {json2xml-5.2.1 → json2xml-5.4.0}/README.rst +128 -12
  4. json2xml-5.4.0/docs/benchmarks.rst +221 -0
  5. {json2xml-5.2.1 → json2xml-5.4.0}/docs/index.rst +1 -0
  6. {json2xml-5.2.1 → json2xml-5.4.0}/docs/installation.rst +45 -2
  7. json2xml-5.4.0/docs/usage.rst +229 -0
  8. {json2xml-5.2.1 → json2xml-5.4.0}/json2xml/__init__.py +1 -1
  9. json2xml-5.4.0/json2xml/cli.py +371 -0
  10. {json2xml-5.2.1 → json2xml-5.4.0}/json2xml/dicttoxml.py +116 -3
  11. {json2xml-5.2.1 → json2xml-5.4.0}/json2xml/json2xml.py +10 -1
  12. {json2xml-5.2.1 → json2xml-5.4.0}/json2xml.egg-info/PKG-INFO +130 -14
  13. {json2xml-5.2.1 → json2xml-5.4.0}/json2xml.egg-info/SOURCES.txt +5 -0
  14. json2xml-5.4.0/json2xml.egg-info/entry_points.txt +2 -0
  15. {json2xml-5.2.1 → json2xml-5.4.0}/json2xml.egg-info/requires.txt +1 -1
  16. {json2xml-5.2.1 → json2xml-5.4.0}/pyproject.toml +8 -2
  17. {json2xml-5.2.1 → json2xml-5.4.0}/setup.cfg +1 -9
  18. {json2xml-5.2.1 → json2xml-5.4.0}/tests/conftest.py +2 -2
  19. json2xml-5.4.0/tests/test_cli.py +685 -0
  20. {json2xml-5.2.1 → json2xml-5.4.0}/tests/test_dict2xml.py +3 -4
  21. {json2xml-5.2.1 → json2xml-5.4.0}/tests/test_json2xml.py +86 -0
  22. json2xml-5.4.0/tests/test_missing_coverage.py +405 -0
  23. {json2xml-5.2.1 → json2xml-5.4.0}/tests/test_utils.py +0 -1
  24. json2xml-5.2.1/docs/usage.rst +0 -7
  25. {json2xml-5.2.1 → json2xml-5.4.0}/AUTHORS.rst +0 -0
  26. {json2xml-5.2.1 → json2xml-5.4.0}/CONTRIBUTING.rst +0 -0
  27. {json2xml-5.2.1 → json2xml-5.4.0}/LICENSE +0 -0
  28. {json2xml-5.2.1 → json2xml-5.4.0}/MANIFEST.in +0 -0
  29. {json2xml-5.2.1 → json2xml-5.4.0}/docs/Makefile +0 -0
  30. {json2xml-5.2.1 → json2xml-5.4.0}/docs/authors.rst +0 -0
  31. {json2xml-5.2.1 → json2xml-5.4.0}/docs/conf.py +0 -0
  32. {json2xml-5.2.1 → json2xml-5.4.0}/docs/contributing.rst +0 -0
  33. {json2xml-5.2.1 → json2xml-5.4.0}/docs/history.rst +0 -0
  34. {json2xml-5.2.1 → json2xml-5.4.0}/docs/json2xml.rst +0 -0
  35. {json2xml-5.2.1 → json2xml-5.4.0}/docs/make.bat +0 -0
  36. {json2xml-5.2.1 → json2xml-5.4.0}/docs/modules.rst +0 -0
  37. {json2xml-5.2.1 → json2xml-5.4.0}/docs/readme.rst +0 -0
  38. {json2xml-5.2.1 → json2xml-5.4.0}/json2xml/utils.py +0 -0
  39. {json2xml-5.2.1 → json2xml-5.4.0}/json2xml.egg-info/dependency_links.txt +0 -0
  40. {json2xml-5.2.1 → json2xml-5.4.0}/json2xml.egg-info/top_level.txt +0 -0
  41. {json2xml-5.2.1 → json2xml-5.4.0}/requirements.in +0 -0
  42. {json2xml-5.2.1 → json2xml-5.4.0}/setup.py +0 -0
  43. {json2xml-5.2.1 → json2xml-5.4.0}/tests/__init__.py +0 -0
@@ -1,6 +1,52 @@
1
1
  History
2
2
  =======
3
3
 
4
+ 5.4.0 / 2026-01-15
5
+ ==================
6
+
7
+ * test: add comprehensive CLI tests for 99% coverage
8
+ * docs: add CLI usage and cross-reference to Go version
9
+ * feat: add CLI support for json2xml-py (#266)
10
+ * chore(deps): bump urllib3 from 2.6.0 to 2.6.3 in /docs (#265)
11
+ * update documentation and make it more correct (#263)
12
+ * feat: update doc packages
13
+ * chore: update GitHub Actions to latest versions (#262)
14
+ * chore(deps): bump urllib3 from 2.5.0 to 2.6.0 in /docs (#261)
15
+ * feat: update python3.15.0 to alpha 3 (#260)
16
+ * feat: bump to match the version
17
+ * feat: add xPath support (#259)
18
+ * chore(deps): bump starlette from 0.47.2 to 0.49.1 in /docs (#257)
19
+ * feat: improvements to ruff and new python 3.15 (#255)
20
+ * Modernize Python code to 3.10+ with pyupgrade (#254)
21
+ * check arm build ubuntu (#253)
22
+ * Remove duplicate typecheck job from pythonpackage workflow
23
+ * Migrate from mypy to ty for type checking (#252)
24
+ * Add Python 3.14t (freethreaded) to testing matrix (#251)
25
+ * prod release (#249)
26
+ * bump python to latest rc2
27
+ * fix: switch to release candidate 2 of Python 3.14
28
+
29
+
30
+ 5.3.1 / 2025-12-08
31
+ ==================
32
+
33
+ * chore: bump version
34
+ * fix: bump version
35
+ * fix: should be all green now
36
+ * lint: fix ossues with lines
37
+ * feat: add missing tests
38
+ * feat: add xPath support
39
+ * chore(deps): bump starlette from 0.47.2 to 0.49.1 in /docs (#257)
40
+ * feat: improvements to ruff and new python 3.15 (#255)
41
+ * Modernize Python code to 3.10+ with pyupgrade (#254)
42
+ * check arm build ubuntu (#253)
43
+ * Remove duplicate typecheck job from pythonpackage workflow
44
+ * Migrate from mypy to ty for type checking (#252)
45
+ * Add Python 3.14t (freethreaded) to testing matrix (#251)
46
+ * prod release (#249)
47
+ * bump python to latest rc2
48
+ * fix: switch to release candidate 2 of Python 3.14
49
+
4
50
  5.2.0 / 2025-07-21
5
51
  ==================
6
52
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: json2xml
3
- Version: 5.2.1
3
+ Version: 5.4.0
4
4
  Summary: Simple Python Library to convert JSON to XML
5
5
  Author-email: Vinit Kumar <mail@vinitkumar.me>
6
6
  License: Apache Software License 2.0
@@ -30,7 +30,7 @@ Requires-Dist: pytest-cov
30
30
  Requires-Dist: coverage
31
31
  Requires-Dist: setuptools
32
32
  Provides-Extra: test
33
- Requires-Dist: pytest==7.0.1; extra == "test"
33
+ Requires-Dist: pytest>=8.4.1; extra == "test"
34
34
  Dynamic: license-file
35
35
 
36
36
  ========
@@ -55,6 +55,8 @@ Documentation: https://json2xml.readthedocs.io.
55
55
 
56
56
  The library was initially dependent on the `dict2xml` project, but it has now been integrated into json2xml itself. This has led to cleaner code, the addition of types and tests, and overall improved performance.
57
57
 
58
+ **Looking for a Go version?** Check out `json2xml-go <https://github.com/vinitkumar/json2xml-go>`_, a Go port of this library with identical features and a native CLI tool.
59
+
58
60
 
59
61
 
60
62
  Architecture Diagram
@@ -63,6 +65,30 @@ Architecture Diagram
63
65
  .. image:: ./diagram.png
64
66
 
65
67
 
68
+ Installation
69
+ ^^^^^^^^^^^^
70
+
71
+ **As a Library**
72
+
73
+ .. code-block:: console
74
+
75
+ pip install json2xml
76
+
77
+ **As a CLI Tool**
78
+
79
+ The library includes a command-line tool ``json2xml-py`` that gets installed automatically:
80
+
81
+ .. code-block:: console
82
+
83
+ pip install json2xml
84
+
85
+ # Now you can use it from the command line
86
+ json2xml-py data.json
87
+ json2xml-py -s '{"name": "John", "age": 30}'
88
+ json2xml-py -u https://api.example.com/data.json
89
+
90
+ For CLI options, run ``json2xml-py --help``.
91
+
66
92
  Features
67
93
  ^^^^^^^^
68
94
 
@@ -71,6 +97,8 @@ json2xml supports the following features:
71
97
  * Conversion from a `json` string to XML
72
98
  * Conversion from a `json` file to XML
73
99
  * Conversion from an API that emits `json` data to XML
100
+ * Compliant with the `json-to-xml` function specification from `XPath 3.1 <https://www.w3.org/TR/xpath-functions-31/#func-json-to-xml>`_
101
+ * **Command-line tool** for easy conversion from the terminal
74
102
 
75
103
  Usage
76
104
  ^^^^^
@@ -202,25 +230,42 @@ You can also specify if the output XML needs to have type specified or not. Here
202
230
 
203
231
  .. code-block:: python
204
232
 
205
- from json2xml import json2xml
206
- from json2xml.utils import readfromurl, readfromstring, readfromjson
233
+ from json2xml import json2xml
234
+ from json2xml.utils import readfromurl, readfromstring, readfromjson
207
235
 
208
- data = readfromstring(
209
- '{"login":"mojombo","id":1,"avatar_url":"https://avatars0.githubusercontent.com/u/1?v=4"}'
210
- )
211
- print(json2xml.Json2xml(data, wrapper="all", pretty=True, attr_type=False).to_xml())
236
+ data = readfromstring(
237
+ '{"login":"mojombo","id":1,"avatar_url":"https://avatars0.githubusercontent.com/u/1?v=4"}'
238
+ )
239
+ print(json2xml.Json2xml(data, wrapper="all", pretty=True, attr_type=False).to_xml())
212
240
 
213
241
 
214
242
  Outputs this:
215
243
 
216
244
  .. code-block:: xml
217
245
 
218
- <?xml version="1.0" ?>
219
- <all>
220
- <login>mojombo</login>
221
- <id>1</id>
222
- <avatar_url>https://avatars0.githubusercontent.com/u/1?v=4</avatar_url>
223
- </all>
246
+ <?xml version="1.0" ?>
247
+ <all>
248
+ <login>mojombo</login>
249
+ <id>1</id>
250
+ <avatar_url>https://avatars0.githubusercontent.com/u/1?v=4</avatar_url>
251
+ </all>
252
+
253
+
254
+ XPath 3.1 Compliance Options
255
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
256
+
257
+ The library supports the optional `xpath_format` parameter which makes the output compliant with the `json-to-xml` function specification from `XPath 3.1 <https://www.w3.org/TR/xpath-functions-31/#func-json-to-xml>`_. When enabled, the XML output follows the standardized format defined by the W3C specification.
258
+
259
+ .. code-block:: python
260
+
261
+ from json2xml import json2xml
262
+ from json2xml.utils import readfromstring
263
+
264
+ data = readfromstring(
265
+ '{"login":"mojombo","id":1,"avatar_url":"https://avatars0.githubusercontent.com/u/1?v=4"}'
266
+ )
267
+ # Use xpath_format=True for XPath 3.1 compliant output
268
+ print(json2xml.Json2xml(data, xpath_format=True).to_xml())
224
269
 
225
270
 
226
271
  The methods are simple and easy to use and there are also checks inside of code to exit cleanly
@@ -272,6 +317,77 @@ Using tools directly:
272
317
  mypy json2xml tests
273
318
 
274
319
 
320
+ CLI Usage
321
+ ^^^^^^^^^
322
+
323
+ The ``json2xml-py`` command-line tool provides an easy way to convert JSON to XML from the terminal.
324
+
325
+ **Basic Examples**
326
+
327
+ .. code-block:: console
328
+
329
+ # Convert a JSON file to XML
330
+ json2xml-py data.json
331
+
332
+ # Convert with custom wrapper element
333
+ json2xml-py -w root data.json
334
+
335
+ # Read JSON from string
336
+ json2xml-py -s '{"name": "John", "age": 30}'
337
+
338
+ # Read from stdin
339
+ cat data.json | json2xml-py -
340
+
341
+ # Output to file
342
+ json2xml-py -o output.xml data.json
343
+
344
+ # Use XPath 3.1 format
345
+ json2xml-py -x data.json
346
+
347
+ # Disable pretty printing and type attributes
348
+ json2xml-py --no-pretty --no-type data.json
349
+
350
+ **CLI Options**
351
+
352
+ .. code-block:: text
353
+
354
+ Input Options:
355
+ -u, --url string Read JSON from URL
356
+ -s, --string string Read JSON from string
357
+ [input-file] Read JSON from file (use - for stdin)
358
+
359
+ Output Options:
360
+ -o, --output string Output file (default: stdout)
361
+
362
+ Conversion Options:
363
+ -w, --wrapper string Wrapper element name (default "all")
364
+ -r, --root Include root element (default true)
365
+ -p, --pretty Pretty print output (default true)
366
+ -t, --type Include type attributes (default true)
367
+ -i, --item-wrap Wrap list items in <item> elements (default true)
368
+ -x, --xpath Use XPath 3.1 json-to-xml format
369
+ -c, --cdata Wrap string values in CDATA sections
370
+ -l, --list-headers Repeat headers for each list item
371
+
372
+ Other Options:
373
+ -v, --version Show version information
374
+ -h, --help Show help message
375
+
376
+
377
+ Go Version
378
+ ^^^^^^^^^^
379
+
380
+ A Go port of this library is available at `json2xml-go <https://github.com/vinitkumar/json2xml-go>`_.
381
+
382
+ **Install the Go CLI:**
383
+
384
+ .. code-block:: console
385
+
386
+ go install github.com/vinitkumar/json2xml-go/cmd/json2xml@latest
387
+
388
+ The Go version provides the same features and a native compiled binary for maximum performance.
389
+
390
+
275
391
  Help and Support to maintain this project
276
392
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
277
393
 
@@ -20,6 +20,8 @@ Documentation: https://json2xml.readthedocs.io.
20
20
 
21
21
  The library was initially dependent on the `dict2xml` project, but it has now been integrated into json2xml itself. This has led to cleaner code, the addition of types and tests, and overall improved performance.
22
22
 
23
+ **Looking for a Go version?** Check out `json2xml-go <https://github.com/vinitkumar/json2xml-go>`_, a Go port of this library with identical features and a native CLI tool.
24
+
23
25
 
24
26
 
25
27
  Architecture Diagram
@@ -28,6 +30,30 @@ Architecture Diagram
28
30
  .. image:: ./diagram.png
29
31
 
30
32
 
33
+ Installation
34
+ ^^^^^^^^^^^^
35
+
36
+ **As a Library**
37
+
38
+ .. code-block:: console
39
+
40
+ pip install json2xml
41
+
42
+ **As a CLI Tool**
43
+
44
+ The library includes a command-line tool ``json2xml-py`` that gets installed automatically:
45
+
46
+ .. code-block:: console
47
+
48
+ pip install json2xml
49
+
50
+ # Now you can use it from the command line
51
+ json2xml-py data.json
52
+ json2xml-py -s '{"name": "John", "age": 30}'
53
+ json2xml-py -u https://api.example.com/data.json
54
+
55
+ For CLI options, run ``json2xml-py --help``.
56
+
31
57
  Features
32
58
  ^^^^^^^^
33
59
 
@@ -36,6 +62,8 @@ json2xml supports the following features:
36
62
  * Conversion from a `json` string to XML
37
63
  * Conversion from a `json` file to XML
38
64
  * Conversion from an API that emits `json` data to XML
65
+ * Compliant with the `json-to-xml` function specification from `XPath 3.1 <https://www.w3.org/TR/xpath-functions-31/#func-json-to-xml>`_
66
+ * **Command-line tool** for easy conversion from the terminal
39
67
 
40
68
  Usage
41
69
  ^^^^^
@@ -167,25 +195,42 @@ You can also specify if the output XML needs to have type specified or not. Here
167
195
 
168
196
  .. code-block:: python
169
197
 
170
- from json2xml import json2xml
171
- from json2xml.utils import readfromurl, readfromstring, readfromjson
198
+ from json2xml import json2xml
199
+ from json2xml.utils import readfromurl, readfromstring, readfromjson
172
200
 
173
- data = readfromstring(
174
- '{"login":"mojombo","id":1,"avatar_url":"https://avatars0.githubusercontent.com/u/1?v=4"}'
175
- )
176
- print(json2xml.Json2xml(data, wrapper="all", pretty=True, attr_type=False).to_xml())
201
+ data = readfromstring(
202
+ '{"login":"mojombo","id":1,"avatar_url":"https://avatars0.githubusercontent.com/u/1?v=4"}'
203
+ )
204
+ print(json2xml.Json2xml(data, wrapper="all", pretty=True, attr_type=False).to_xml())
177
205
 
178
206
 
179
207
  Outputs this:
180
208
 
181
209
  .. code-block:: xml
182
210
 
183
- <?xml version="1.0" ?>
184
- <all>
185
- <login>mojombo</login>
186
- <id>1</id>
187
- <avatar_url>https://avatars0.githubusercontent.com/u/1?v=4</avatar_url>
188
- </all>
211
+ <?xml version="1.0" ?>
212
+ <all>
213
+ <login>mojombo</login>
214
+ <id>1</id>
215
+ <avatar_url>https://avatars0.githubusercontent.com/u/1?v=4</avatar_url>
216
+ </all>
217
+
218
+
219
+ XPath 3.1 Compliance Options
220
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
221
+
222
+ The library supports the optional `xpath_format` parameter which makes the output compliant with the `json-to-xml` function specification from `XPath 3.1 <https://www.w3.org/TR/xpath-functions-31/#func-json-to-xml>`_. When enabled, the XML output follows the standardized format defined by the W3C specification.
223
+
224
+ .. code-block:: python
225
+
226
+ from json2xml import json2xml
227
+ from json2xml.utils import readfromstring
228
+
229
+ data = readfromstring(
230
+ '{"login":"mojombo","id":1,"avatar_url":"https://avatars0.githubusercontent.com/u/1?v=4"}'
231
+ )
232
+ # Use xpath_format=True for XPath 3.1 compliant output
233
+ print(json2xml.Json2xml(data, xpath_format=True).to_xml())
189
234
 
190
235
 
191
236
  The methods are simple and easy to use and there are also checks inside of code to exit cleanly
@@ -237,6 +282,77 @@ Using tools directly:
237
282
  mypy json2xml tests
238
283
 
239
284
 
285
+ CLI Usage
286
+ ^^^^^^^^^
287
+
288
+ The ``json2xml-py`` command-line tool provides an easy way to convert JSON to XML from the terminal.
289
+
290
+ **Basic Examples**
291
+
292
+ .. code-block:: console
293
+
294
+ # Convert a JSON file to XML
295
+ json2xml-py data.json
296
+
297
+ # Convert with custom wrapper element
298
+ json2xml-py -w root data.json
299
+
300
+ # Read JSON from string
301
+ json2xml-py -s '{"name": "John", "age": 30}'
302
+
303
+ # Read from stdin
304
+ cat data.json | json2xml-py -
305
+
306
+ # Output to file
307
+ json2xml-py -o output.xml data.json
308
+
309
+ # Use XPath 3.1 format
310
+ json2xml-py -x data.json
311
+
312
+ # Disable pretty printing and type attributes
313
+ json2xml-py --no-pretty --no-type data.json
314
+
315
+ **CLI Options**
316
+
317
+ .. code-block:: text
318
+
319
+ Input Options:
320
+ -u, --url string Read JSON from URL
321
+ -s, --string string Read JSON from string
322
+ [input-file] Read JSON from file (use - for stdin)
323
+
324
+ Output Options:
325
+ -o, --output string Output file (default: stdout)
326
+
327
+ Conversion Options:
328
+ -w, --wrapper string Wrapper element name (default "all")
329
+ -r, --root Include root element (default true)
330
+ -p, --pretty Pretty print output (default true)
331
+ -t, --type Include type attributes (default true)
332
+ -i, --item-wrap Wrap list items in <item> elements (default true)
333
+ -x, --xpath Use XPath 3.1 json-to-xml format
334
+ -c, --cdata Wrap string values in CDATA sections
335
+ -l, --list-headers Repeat headers for each list item
336
+
337
+ Other Options:
338
+ -v, --version Show version information
339
+ -h, --help Show help message
340
+
341
+
342
+ Go Version
343
+ ^^^^^^^^^^
344
+
345
+ A Go port of this library is available at `json2xml-go <https://github.com/vinitkumar/json2xml-go>`_.
346
+
347
+ **Install the Go CLI:**
348
+
349
+ .. code-block:: console
350
+
351
+ go install github.com/vinitkumar/json2xml-go/cmd/json2xml@latest
352
+
353
+ The Go version provides the same features and a native compiled binary for maximum performance.
354
+
355
+
240
356
  Help and Support to maintain this project
241
357
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
242
358
 
@@ -0,0 +1,221 @@
1
+ Benchmarks
2
+ ==========
3
+
4
+ Comprehensive performance comparison between Python implementations and the Go version of json2xml.
5
+
6
+ Test Environment
7
+ ----------------
8
+
9
+ * **Machine**: Apple Silicon (aarch64)
10
+ * **OS**: macOS
11
+ * **Date**: January 14, 2026
12
+
13
+ Implementations Tested
14
+ ~~~~~~~~~~~~~~~~~~~~~~
15
+
16
+ .. list-table::
17
+ :header-rows: 1
18
+ :widths: 30 20 50
19
+
20
+ * - Implementation
21
+ - Version
22
+ - Notes
23
+ * - CPython
24
+ - 3.14.2
25
+ - Homebrew installation
26
+ * - CPython
27
+ - 3.15.0a4
28
+ - Latest alpha via uv
29
+ * - PyPy
30
+ - 3.10.16
31
+ - JIT-compiled Python
32
+ * - Go
33
+ - 1.0.0
34
+ - json2xml-go
35
+
36
+ Test Data
37
+ ~~~~~~~~~
38
+
39
+ .. list-table::
40
+ :header-rows: 1
41
+ :widths: 20 50 30
42
+
43
+ * - Size
44
+ - Description
45
+ - Bytes
46
+ * - Small
47
+ - Simple object ``{"name": "John", "age": 30, "city": "New York"}``
48
+ - 47
49
+ * - Medium
50
+ - ``bigexample.json`` (patent data)
51
+ - 2,598
52
+ * - Large
53
+ - 1,000 generated records with nested structures
54
+ - 323,130
55
+ * - Very Large
56
+ - 5,000 generated records with nested structures
57
+ - 1,619,991
58
+
59
+ Results
60
+ -------
61
+
62
+ Individual Test Results
63
+ ~~~~~~~~~~~~~~~~~~~~~~~
64
+
65
+ .. list-table::
66
+ :header-rows: 1
67
+ :widths: 25 20 20 20 15
68
+
69
+ * - Test
70
+ - CPython 3.14.2
71
+ - CPython 3.15.0a4
72
+ - PyPy 3.10.16
73
+ - Go
74
+ * - **Small JSON** (47 bytes)
75
+ - 75.46ms
76
+ - 55.74ms (1.4x faster)
77
+ - 121.47ms (1.6x slower)
78
+ - 3.69ms (20.4x faster)
79
+ * - **Medium JSON** (2.6KB)
80
+ - 73.87ms
81
+ - 57.98ms (1.3x faster)
82
+ - 125.73ms (1.7x slower)
83
+ - 4.32ms (17.1x faster)
84
+ * - **Large JSON** (323KB)
85
+ - 419.67ms
86
+ - 328.98ms (1.3x faster)
87
+ - 517.51ms (1.2x slower)
88
+ - 67.13ms (6.3x faster)
89
+ * - **Very Large JSON** (1.6MB)
90
+ - 2.09s
91
+ - 1.86s (1.1x faster)
92
+ - 1.42s (1.5x faster)
93
+ - 287.58ms (7.3x faster)
94
+
95
+ Summary (Average Across All Tests)
96
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97
+
98
+ .. list-table::
99
+ :header-rows: 1
100
+ :widths: 40 30 30
101
+
102
+ * - Implementation
103
+ - Avg Time
104
+ - vs CPython 3.14.2
105
+ * - **Go**
106
+ - 90.68ms
107
+ - **7.34x faster** 🚀
108
+ * - **PyPy 3.10.16**
109
+ - 545.58ms
110
+ - **1.22x faster**
111
+ * - **CPython 3.15.0a4**
112
+ - 575.45ms
113
+ - **1.16x faster**
114
+ * - **CPython 3.14.2**
115
+ - 665.23ms
116
+ - baseline
117
+
118
+ Key Observations
119
+ ----------------
120
+
121
+ 1. Go is the Clear Winner
122
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
123
+
124
+ Go outperforms all Python implementations by a significant margin:
125
+
126
+ * **7.34x faster** than CPython 3.14.2 on average
127
+ * Up to **20x faster** for small inputs due to minimal startup overhead
128
+ * Consistent performance across all input sizes
129
+
130
+ 2. CPython 3.15.0a4 Shows Promising Improvements
131
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
132
+
133
+ The latest Python alpha demonstrates consistent performance gains:
134
+
135
+ * **13-35% faster** than CPython 3.14.2 across all test sizes
136
+ * Improvements likely due to ongoing interpreter optimizations
137
+
138
+ 3. PyPy Has Interesting Trade-offs
139
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
140
+
141
+ PyPy's JIT compiler creates a unique performance profile:
142
+
143
+ * **Slower for small/medium inputs**: JIT compilation overhead hurts for quick operations
144
+ * **Faster for very large inputs**: JIT shines on the 5K record test (1.5x faster than CPython)
145
+ * Best suited for long-running processes or batch processing
146
+
147
+ 4. Startup Overhead Dominates Small Inputs
148
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
149
+
150
+ Python's interpreter startup time is significant:
151
+
152
+ * CPython takes **55-75ms** even for 47 bytes of JSON
153
+ * Go takes only **3.7ms** for the same operation
154
+ * For CLI tools processing small files, Go provides a much better user experience
155
+
156
+ When to Use Each Implementation
157
+ -------------------------------
158
+
159
+ .. list-table::
160
+ :header-rows: 1
161
+ :widths: 50 50
162
+
163
+ * - Use Case
164
+ - Recommended
165
+ * - CLI tool for small/medium files
166
+ - **Go** (json2xml-go)
167
+ * - High-throughput batch processing
168
+ - **Go** or **PyPy**
169
+ * - Integration with Python codebase
170
+ - **CPython 3.15+**
171
+ * - One-off conversions in scripts
172
+ - **CPython** (any version)
173
+
174
+ Running the Benchmarks
175
+ ----------------------
176
+
177
+ Python Multi-Implementation Benchmark
178
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
179
+
180
+ .. code-block:: bash
181
+
182
+ # Set the Go CLI path
183
+ export JSON2XML_GO_CLI=/path/to/json2xml-go
184
+
185
+ # Run the benchmark
186
+ python benchmark_multi_python.py
187
+
188
+ Simple Python vs Go Benchmark
189
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190
+
191
+ .. code-block:: bash
192
+
193
+ # Set paths via environment variables (optional)
194
+ export JSON2XML_GO_CLI=/path/to/json2xml-go
195
+ export JSON2XML_EXAMPLES_DIR=/path/to/examples
196
+
197
+ # Run the benchmark
198
+ python benchmark.py
199
+
200
+ Reproducing Results
201
+ -------------------
202
+
203
+ 1. Install required Python versions using ``uv``:
204
+
205
+ .. code-block:: bash
206
+
207
+ uv python install 3.14 3.15.0a4 pypy@3.10
208
+
209
+ 2. Build the Go binary:
210
+
211
+ .. code-block:: bash
212
+
213
+ cd /path/to/json2xml-go
214
+ go build -o json2xml-go ./cmd/json2xml-go
215
+
216
+ 3. Run the multi-Python benchmark:
217
+
218
+ .. code-block:: bash
219
+
220
+ cd /path/to/json2xml
221
+ python benchmark_multi_python.py
@@ -8,6 +8,7 @@ Welcome to json2xml's documentation!
8
8
  readme
9
9
  installation
10
10
  usage
11
+ benchmarks
11
12
  modules
12
13
  contributing
13
14
  authors