jsonyx 2.2.0__tar.gz → 2.3.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 (33) hide show
  1. {jsonyx-2.2.0/src/jsonyx.egg-info → jsonyx-2.3.0}/PKG-INFO +118 -118
  2. {jsonyx-2.2.0 → jsonyx-2.3.0}/README.md +22 -22
  3. {jsonyx-2.2.0 → jsonyx-2.3.0}/setup.cfg +4 -4
  4. {jsonyx-2.2.0 → jsonyx-2.3.0}/setup.py +54 -54
  5. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/__init__.py +3 -3
  6. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/__main__.py +2 -1
  7. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/_decoder.py +19 -13
  8. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/_differ.py +4 -4
  9. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/_encoder.py +10 -12
  10. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/_speedups.c +2265 -2255
  11. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_dumps.py +682 -682
  12. {jsonyx-2.2.0 → jsonyx-2.3.0/src/jsonyx.egg-info}/PKG-INFO +118 -118
  13. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx.egg-info/SOURCES.txt +0 -1
  14. {jsonyx-2.2.0 → jsonyx-2.3.0}/LICENSE +0 -0
  15. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/_manipulator.py +0 -0
  16. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/allow.py +0 -0
  17. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/py.typed +0 -0
  18. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/__init__.py +0 -0
  19. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/conftest.py +0 -0
  20. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_apply_filter.py +0 -0
  21. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_apply_patch.py +0 -0
  22. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_dump.py +0 -0
  23. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_jsonyx.py +0 -0
  24. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_load_query_value.py +0 -0
  25. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_loads.py +0 -0
  26. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_make_patch.py +0 -0
  27. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_paste_values.py +0 -0
  28. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_select_nodes.py +0 -0
  29. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_syntax_error.py +0 -0
  30. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx/test/test_write.py +0 -0
  31. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx.egg-info/dependency_links.txt +0 -0
  32. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx.egg-info/entry_points.txt +0 -0
  33. {jsonyx-2.2.0 → jsonyx-2.3.0}/src/jsonyx.egg-info/top_level.txt +0 -0
@@ -1,118 +1,118 @@
1
- Metadata-Version: 2.4
2
- Name: jsonyx
3
- Version: 2.2.0
4
- Summary: Customizable JSON library for Python
5
- Author: Nice Zombies
6
- Author-email: nineteendo19d0@gmail.com
7
- Maintainer: Nice Zombies
8
- Maintainer-email: nineteendo19d0@gmail.com
9
- License: GPL-3.0
10
- Project-URL: Homepage, https://github.com/nineteendo/jsonyx
11
- Project-URL: Changelog, https://jsonyx.readthedocs.io/en/latest/changelog.html
12
- Project-URL: Documentation, https://jsonyx.readthedocs.io
13
- Project-URL: Issues, https://github.com/nineteendo/jsonyx/issues
14
- Project-URL: Sponser, https://paypal.me/nineteendo
15
- Keywords: python,json,json-parser
16
- Classifier: Development Status :: 5 - Production/Stable
17
- Classifier: Intended Audience :: Developers
18
- Classifier: Operating System :: OS Independent
19
- Classifier: Programming Language :: Python :: 3 :: Only
20
- Classifier: Programming Language :: Python :: 3.8
21
- Classifier: Programming Language :: Python :: 3.9
22
- Classifier: Programming Language :: Python :: 3.10
23
- Classifier: Programming Language :: Python :: 3.11
24
- Classifier: Programming Language :: Python :: 3.12
25
- Classifier: Programming Language :: Python :: 3.13
26
- Classifier: Programming Language :: Python :: 3.14
27
- Requires-Python: >=3.8
28
- Description-Content-Type: text/markdown
29
- License-File: LICENSE
30
- Dynamic: author
31
- Dynamic: author-email
32
- Dynamic: classifier
33
- Dynamic: description
34
- Dynamic: description-content-type
35
- Dynamic: keywords
36
- Dynamic: license
37
- Dynamic: license-file
38
- Dynamic: maintainer
39
- Dynamic: maintainer-email
40
- Dynamic: project-url
41
- Dynamic: requires-python
42
- Dynamic: summary
43
-
44
- # jsonyx
45
-
46
- [![pypi](https://img.shields.io/pypi/v/jsonyx.svg)](http://pypi.org/project/jsonyx)
47
- [![conda-forge](https://img.shields.io/conda/vn/conda-forge/jsonyx.svg)](https://anaconda.org/conda-forge/jsonyx)
48
- [![python](https://img.shields.io/pypi/pyversions/jsonyx.svg)](http://pypi.org/project/jsonyx)
49
- [![license](https://img.shields.io/pypi/l/jsonyx.svg)](http://pypi.org/project/jsonyx)
50
- [![pytest](https://github.com/nineteendo/jsonyx/actions/workflows/pytest.yml/badge.svg?branch=2.2.x)](https://github.com/nineteendo/jsonyx/actions/workflows/pytest.yml)
51
- [![docs](https://readthedocs.org/projects/jsonyx/badge/?version=stable)](https://jsonyx.readthedocs.io/en/stable/?badge=stable)
52
- [![downloads](https://img.shields.io/pypi/dm/jsonyx.svg)](http://pypi.org/project/jsonyx)
53
-
54
- `jsonyx` is a customizable [JSON](http://json.org) library for Python 3.8+. It
55
- is written in pure Python with an optional C extension for better performance
56
- and no dependencies.
57
-
58
- The documentation for `jsonyx` is available online at: https://jsonyx.readthedocs.io
59
-
60
- ## Key Features
61
-
62
- - JSON decoding, encoding and patching
63
- - Pretty printing:
64
- ```json
65
- {
66
- "foo": [1, 2, 3],
67
- "bar": {"a": 1, "b": 2, "c": 3}
68
- }
69
- ```
70
- - Optionally supports these JSON deviations (specified in the documentation):
71
- ```javascript
72
- {
73
- /* Block */ // and line comments
74
- "Missing commas": [1 2 3],
75
- "NaN and infinity": [NaN, Infinity, -Infinity],
76
- "Surrogates": "\ud800",
77
- "Trailing comma": [0,],
78
- "Unquoted keys": {key: "value"}
79
- }
80
- ```
81
- - Detailed error messages:
82
- ```none
83
- Traceback (most recent call last):
84
- File "/Users/wannes/Downloads/broken.json", line 1, column 99-381
85
- ...sList": {"GlossEntry": {"ID": "SGM..."GML", "XML"]}, "GlossSee": "markup"
86
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87
- jsonyx.JSONSyntaxError: Unterminated object
88
- ```
89
- - Dedicated functions for reading and writing files and pretty printing
90
-
91
- ## Benchmark (Mar 31, 2025)
92
-
93
- We recommend to use [`orjson`](https://pypi.org/project/orjson),
94
- [`msgspec`](https://pypi.org/project/msgspec) or
95
- [`pysimdjson`](https://pypi.org/project/pysimdjson) for performance critical
96
- applications:
97
-
98
- | encode | json | jsonyx | msgspec | orjson | fastest time |
99
- |:--------------------------------------------|-------:|-------:|--------:|--------:|-------------:|
100
- | List of 256 booleans | 4.56x | 5.33x | 1.00x | 1.06x | 1.90 μs |
101
- | List of 256 ASCII strings | 12.12x | 13.65x | 1.50x | 1.00x | 3.95 μs |
102
- | List of 256 floats | 23.41x | 25.95x | 1.30x | 1.00x | 8.03 μs |
103
- | List of 256 dicts with 1 int | 11.10x | 13.61x | 1.32x | 1.00x | 7.75 μs |
104
- | Medium complex object | 10.76x | 11.80x | 1.16x | 1.00x | 13.30 μs |
105
- | List of 256 strings | 23.08x | 19.66x | 2.04x | 1.00x | 14.42 μs |
106
- | Complex object | 7.36x | 7.95x | 1.00x | DNF | 209.74 μs |
107
- | Dict with 256 lists of 256 dicts with 1 int | 9.23x | 11.34x | 1.21x | 1.00x | 2361.90 μs |
108
-
109
- | decode | json | jsonyx | msgspec | orjson | simdjson | fastest time |
110
- |:--------------------------------------------|-------:|-------:|--------:|-------:|---------:|-------------:|
111
- | List of 256 booleans | 4.40x | 6.26x | 2.60x | 1.28x | 1.00x | 1.54 μs |
112
- | List of 256 ASCII strings | 9.08x | 12.57x | 5.43x | 5.03x | 1.00x | 2.89 μs |
113
- | List of 256 floats | 10.99x | 12.47x | 2.32x | 1.78x | 1.00x | 6.14 μs |
114
- | List of 256 dicts with 1 int | 12.11x | 15.16x | 6.87x | 5.08x | 1.00x | 6.17 μs |
115
- | Medium complex object | 12.65x | 17.63x | 5.26x | 4.40x | 1.00x | 7.62 μs |
116
- | List of 256 strings | 5.68x | 4.38x | 9.92x | 8.00x | 1.00x | 16.76 μs |
117
- | Complex object | 8.58x | 7.54x | 8.32x | 7.56x | 1.00x | 136.79 μs |
118
- | Dict with 256 lists of 256 dicts with 1 int | 17.65x | 19.13x | 12.07x | 10.78x | 1.00x | 1658.37 μs |
1
+ Metadata-Version: 2.4
2
+ Name: jsonyx
3
+ Version: 2.3.0
4
+ Summary: Customizable JSON library for Python
5
+ Author: Nice Zombies
6
+ Author-email: nineteendo19d0@gmail.com
7
+ Maintainer: Nice Zombies
8
+ Maintainer-email: nineteendo19d0@gmail.com
9
+ License: GPL-3.0
10
+ Project-URL: Homepage, https://github.com/nineteendo/jsonyx
11
+ Project-URL: Changelog, https://jsonyx.readthedocs.io/en/latest/changelog.html
12
+ Project-URL: Documentation, https://jsonyx.readthedocs.io
13
+ Project-URL: Issues, https://github.com/nineteendo/jsonyx/issues
14
+ Project-URL: Sponser, https://paypal.me/nineteendo
15
+ Keywords: python,json,json-parser
16
+ Classifier: Development Status :: 5 - Production/Stable
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.8
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Programming Language :: Python :: 3.14
27
+ Requires-Python: >=3.8
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Dynamic: author
31
+ Dynamic: author-email
32
+ Dynamic: classifier
33
+ Dynamic: description
34
+ Dynamic: description-content-type
35
+ Dynamic: keywords
36
+ Dynamic: license
37
+ Dynamic: license-file
38
+ Dynamic: maintainer
39
+ Dynamic: maintainer-email
40
+ Dynamic: project-url
41
+ Dynamic: requires-python
42
+ Dynamic: summary
43
+
44
+ # jsonyx
45
+
46
+ [![pypi](https://img.shields.io/pypi/v/jsonyx.svg)](http://pypi.org/project/jsonyx)
47
+ [![conda-forge](https://img.shields.io/conda/vn/conda-forge/jsonyx.svg)](https://anaconda.org/conda-forge/jsonyx)
48
+ [![python](https://img.shields.io/pypi/pyversions/jsonyx.svg)](http://pypi.org/project/jsonyx)
49
+ [![license](https://img.shields.io/pypi/l/jsonyx.svg)](http://pypi.org/project/jsonyx)
50
+ [![pytest](https://github.com/nineteendo/jsonyx/actions/workflows/pytest.yml/badge.svg?branch=2.3.x)](https://github.com/nineteendo/jsonyx/actions/workflows/pytest.yml)
51
+ [![docs](https://readthedocs.org/projects/jsonyx/badge/?version=stable)](https://jsonyx.readthedocs.io/en/stable/?badge=stable)
52
+ [![downloads](https://img.shields.io/pypi/dm/jsonyx.svg)](http://pypi.org/project/jsonyx)
53
+
54
+ `jsonyx` is a customizable [JSON](http://json.org) library for Python 3.8+. It
55
+ is written in pure Python with an optional C extension for better performance
56
+ and no dependencies.
57
+
58
+ The documentation for `jsonyx` is available online at: https://jsonyx.readthedocs.io
59
+
60
+ ## Key Features
61
+
62
+ - JSON decoding, encoding and patching
63
+ - Pretty printing:
64
+ ```json
65
+ {
66
+ "foo": [1, 2, 3],
67
+ "bar": {"a": 1, "b": 2, "c": 3}
68
+ }
69
+ ```
70
+ - Optionally supports these JSON deviations (specified in the documentation):
71
+ ```javascript
72
+ {
73
+ /* Block */ // and line comments
74
+ "Missing commas": [1 2 3],
75
+ "NaN and infinity": [NaN, Infinity, -Infinity],
76
+ "Surrogates": "\ud800",
77
+ "Trailing comma": [0,],
78
+ "Unquoted keys": {key: "value"}
79
+ }
80
+ ```
81
+ - Detailed error messages:
82
+ ```none
83
+ Traceback (most recent call last):
84
+ File "/Users/wannes/Downloads/broken.json", line 1, column 99-381
85
+ ...sList": {"GlossEntry": {"ID": "SGM..."GML", "XML"]}, "GlossSee": "markup"
86
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87
+ jsonyx.JSONSyntaxError: Unterminated object
88
+ ```
89
+ - Dedicated functions for reading and writing files and pretty printing
90
+
91
+ ## Benchmark (Apr 30, 2025)
92
+
93
+ We recommend to use [`orjson`](https://pypi.org/project/orjson),
94
+ [`msgspec`](https://pypi.org/project/msgspec) or
95
+ [`pysimdjson`](https://pypi.org/project/pysimdjson) for performance critical
96
+ applications:
97
+
98
+ | encode | json | jsonyx | msgspec | orjson | fastest time |
99
+ |:--------------------------------------------|-------:|-------:|--------:|-------:|-------------:|
100
+ | List of 256 booleans | 4.62x | 4.17x | 1.06x | 1.00x | 1.82 μs |
101
+ | List of 256 ASCII strings | 14.09x | 8.10x | 1.66x | 1.00x | 3.66 μs |
102
+ | List of 256 floats | 25.20x | 25.18x | 1.33x | 1.00x | 8.07 μs |
103
+ | List of 256 dicts with 1 int | 11.24x | 9.89x | 1.34x | 1.00x | 7.87 μs |
104
+ | Medium complex object | 10.21x | 8.85x | 1.17x | 1.00x | 13.87 μs |
105
+ | List of 256 strings | 26.46x | 15.18x | 2.23x | 1.00x | 13.37 μs |
106
+ | Complex object | 7.86x | 7.41x | 1.00x | DNF | 207.83 μs |
107
+ | Dict with 256 lists of 256 dicts with 1 int | 9.87x | 8.72x | 1.24x | 1.00x | 2295.24 μs |
108
+
109
+ | decode | json | jsonyx | msgspec | orjson | simdjson | fastest time |
110
+ |:--------------------------------------------|-------:|--------:|--------:|-------:|---------:|-------------:|
111
+ | List of 256 booleans | 4.70x | 5.22x | 2.92x | 1.41x | 1.00x | 1.45 μs |
112
+ | List of 256 ASCII strings | 9.04x | 7.05x | 4.85x | 4.43x | 1.00x | 3.15 μs |
113
+ | List of 256 floats | 10.91x | 11.22x | 2.24x | 1.73x | 1.00x | 6.14 μs |
114
+ | List of 256 dicts with 1 int | 12.99x | 11.65x | 7.35x | 5.30x | 1.00x | 6.11 μs |
115
+ | Medium complex object | 13.41x | 12.94x | 5.44x | 4.67x | 1.00x | 7.65 μs |
116
+ | List of 256 strings | 6.85x | 3.75x | 9.56x | 7.85x | 1.00x | 16.78 μs |
117
+ | Complex object | 9.36x | 7.63x | 8.55x | 7.67x | 1.00x | 136.11 μs |
118
+ | Dict with 256 lists of 256 dicts with 1 int | 19.03x | 15.62x | 11.58x | 9.87x | 1.00x | 1640.77 μs |
@@ -4,7 +4,7 @@
4
4
  [![conda-forge](https://img.shields.io/conda/vn/conda-forge/jsonyx.svg)](https://anaconda.org/conda-forge/jsonyx)
5
5
  [![python](https://img.shields.io/pypi/pyversions/jsonyx.svg)](http://pypi.org/project/jsonyx)
6
6
  [![license](https://img.shields.io/pypi/l/jsonyx.svg)](http://pypi.org/project/jsonyx)
7
- [![pytest](https://github.com/nineteendo/jsonyx/actions/workflows/pytest.yml/badge.svg?branch=2.2.x)](https://github.com/nineteendo/jsonyx/actions/workflows/pytest.yml)
7
+ [![pytest](https://github.com/nineteendo/jsonyx/actions/workflows/pytest.yml/badge.svg?branch=2.3.x)](https://github.com/nineteendo/jsonyx/actions/workflows/pytest.yml)
8
8
  [![docs](https://readthedocs.org/projects/jsonyx/badge/?version=stable)](https://jsonyx.readthedocs.io/en/stable/?badge=stable)
9
9
  [![downloads](https://img.shields.io/pypi/dm/jsonyx.svg)](http://pypi.org/project/jsonyx)
10
10
 
@@ -45,31 +45,31 @@ The documentation for `jsonyx` is available online at: https://jsonyx.readthedoc
45
45
  ```
46
46
  - Dedicated functions for reading and writing files and pretty printing
47
47
 
48
- ## Benchmark (Mar 31, 2025)
48
+ ## Benchmark (Apr 30, 2025)
49
49
 
50
50
  We recommend to use [`orjson`](https://pypi.org/project/orjson),
51
51
  [`msgspec`](https://pypi.org/project/msgspec) or
52
52
  [`pysimdjson`](https://pypi.org/project/pysimdjson) for performance critical
53
53
  applications:
54
54
 
55
- | encode | json | jsonyx | msgspec | orjson | fastest time |
56
- |:--------------------------------------------|-------:|-------:|--------:|--------:|-------------:|
57
- | List of 256 booleans | 4.56x | 5.33x | 1.00x | 1.06x | 1.90 μs |
58
- | List of 256 ASCII strings | 12.12x | 13.65x | 1.50x | 1.00x | 3.95 μs |
59
- | List of 256 floats | 23.41x | 25.95x | 1.30x | 1.00x | 8.03 μs |
60
- | List of 256 dicts with 1 int | 11.10x | 13.61x | 1.32x | 1.00x | 7.75 μs |
61
- | Medium complex object | 10.76x | 11.80x | 1.16x | 1.00x | 13.30 μs |
62
- | List of 256 strings | 23.08x | 19.66x | 2.04x | 1.00x | 14.42 μs |
63
- | Complex object | 7.36x | 7.95x | 1.00x | DNF | 209.74 μs |
64
- | Dict with 256 lists of 256 dicts with 1 int | 9.23x | 11.34x | 1.21x | 1.00x | 2361.90 μs |
55
+ | encode | json | jsonyx | msgspec | orjson | fastest time |
56
+ |:--------------------------------------------|-------:|-------:|--------:|-------:|-------------:|
57
+ | List of 256 booleans | 4.62x | 4.17x | 1.06x | 1.00x | 1.82 μs |
58
+ | List of 256 ASCII strings | 14.09x | 8.10x | 1.66x | 1.00x | 3.66 μs |
59
+ | List of 256 floats | 25.20x | 25.18x | 1.33x | 1.00x | 8.07 μs |
60
+ | List of 256 dicts with 1 int | 11.24x | 9.89x | 1.34x | 1.00x | 7.87 μs |
61
+ | Medium complex object | 10.21x | 8.85x | 1.17x | 1.00x | 13.87 μs |
62
+ | List of 256 strings | 26.46x | 15.18x | 2.23x | 1.00x | 13.37 μs |
63
+ | Complex object | 7.86x | 7.41x | 1.00x | DNF | 207.83 μs |
64
+ | Dict with 256 lists of 256 dicts with 1 int | 9.87x | 8.72x | 1.24x | 1.00x | 2295.24 μs |
65
65
 
66
- | decode | json | jsonyx | msgspec | orjson | simdjson | fastest time |
67
- |:--------------------------------------------|-------:|-------:|--------:|-------:|---------:|-------------:|
68
- | List of 256 booleans | 4.40x | 6.26x | 2.60x | 1.28x | 1.00x | 1.54 μs |
69
- | List of 256 ASCII strings | 9.08x | 12.57x | 5.43x | 5.03x | 1.00x | 2.89 μs |
70
- | List of 256 floats | 10.99x | 12.47x | 2.32x | 1.78x | 1.00x | 6.14 μs |
71
- | List of 256 dicts with 1 int | 12.11x | 15.16x | 6.87x | 5.08x | 1.00x | 6.17 μs |
72
- | Medium complex object | 12.65x | 17.63x | 5.26x | 4.40x | 1.00x | 7.62 μs |
73
- | List of 256 strings | 5.68x | 4.38x | 9.92x | 8.00x | 1.00x | 16.76 μs |
74
- | Complex object | 8.58x | 7.54x | 8.32x | 7.56x | 1.00x | 136.79 μs |
75
- | Dict with 256 lists of 256 dicts with 1 int | 17.65x | 19.13x | 12.07x | 10.78x | 1.00x | 1658.37 μs |
66
+ | decode | json | jsonyx | msgspec | orjson | simdjson | fastest time |
67
+ |:--------------------------------------------|-------:|--------:|--------:|-------:|---------:|-------------:|
68
+ | List of 256 booleans | 4.70x | 5.22x | 2.92x | 1.41x | 1.00x | 1.45 μs |
69
+ | List of 256 ASCII strings | 9.04x | 7.05x | 4.85x | 4.43x | 1.00x | 3.15 μs |
70
+ | List of 256 floats | 10.91x | 11.22x | 2.24x | 1.73x | 1.00x | 6.14 μs |
71
+ | List of 256 dicts with 1 int | 12.99x | 11.65x | 7.35x | 5.30x | 1.00x | 6.11 μs |
72
+ | Medium complex object | 13.41x | 12.94x | 5.44x | 4.67x | 1.00x | 7.65 μs |
73
+ | List of 256 strings | 6.85x | 3.75x | 9.56x | 7.85x | 1.00x | 16.78 μs |
74
+ | Complex object | 9.36x | 7.63x | 8.55x | 7.67x | 1.00x | 136.11 μs |
75
+ | Dict with 256 lists of 256 dicts with 1 int | 19.03x | 15.62x | 11.58x | 9.87x | 1.00x | 1640.77 μs |
@@ -1,4 +1,4 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -1,54 +1,54 @@
1
- """jsonyx setup."""
2
- from __future__ import annotations
3
-
4
- __all__: list[str] = []
5
-
6
- from pathlib import Path
7
-
8
- # pylint: disable-next=E0401
9
- from setuptools import Extension, setup # type: ignore
10
-
11
- if __name__ == "__main__":
12
- setup(
13
- name="jsonyx",
14
- version="2.2.0",
15
- description="Customizable JSON library for Python",
16
- long_description=Path("README.md").read_text(encoding="utf-8"),
17
- long_description_content_type="text/markdown",
18
- author="Nice Zombies",
19
- author_email="nineteendo19d0@gmail.com",
20
- maintainer="Nice Zombies",
21
- maintainer_email="nineteendo19d0@gmail.com",
22
- packages=["jsonyx", "jsonyx.test"],
23
- ext_modules=[
24
- Extension("_jsonyx", ["src/jsonyx/_speedups.c"], optional=True),
25
- ],
26
- classifiers=[
27
- "Development Status :: 5 - Production/Stable",
28
- "Intended Audience :: Developers",
29
- "Operating System :: OS Independent",
30
- "Programming Language :: Python :: 3 :: Only",
31
- "Programming Language :: Python :: 3.8",
32
- "Programming Language :: Python :: 3.9",
33
- "Programming Language :: Python :: 3.10",
34
- "Programming Language :: Python :: 3.11",
35
- "Programming Language :: Python :: 3.12",
36
- "Programming Language :: Python :: 3.13",
37
- "Programming Language :: Python :: 3.14",
38
- ],
39
- license="GPL-3.0",
40
- keywords=["python", "json", "json-parser"],
41
- package_dir={"": "src"},
42
- # setuptools arguments
43
- entry_points={"console_scripts": ["jsonyx = jsonyx.__main__:main"]},
44
- python_requires=">=3.8",
45
- project_urls={
46
- "Homepage": "https://github.com/nineteendo/jsonyx",
47
- "Changelog": (
48
- "https://jsonyx.readthedocs.io/en/latest/changelog.html"
49
- ),
50
- "Documentation": "https://jsonyx.readthedocs.io",
51
- "Issues": "https://github.com/nineteendo/jsonyx/issues",
52
- "Sponser": "https://paypal.me/nineteendo",
53
- },
54
- )
1
+ """jsonyx setup."""
2
+ from __future__ import annotations
3
+
4
+ __all__: list[str] = []
5
+
6
+ from pathlib import Path
7
+
8
+ # pylint: disable-next=E0401
9
+ from setuptools import Extension, setup # type: ignore
10
+
11
+ if __name__ == "__main__":
12
+ setup(
13
+ name="jsonyx",
14
+ version="2.3.0",
15
+ description="Customizable JSON library for Python",
16
+ long_description=Path("README.md").read_text(encoding="utf-8"),
17
+ long_description_content_type="text/markdown",
18
+ author="Nice Zombies",
19
+ author_email="nineteendo19d0@gmail.com",
20
+ maintainer="Nice Zombies",
21
+ maintainer_email="nineteendo19d0@gmail.com",
22
+ packages=["jsonyx", "jsonyx.test"],
23
+ ext_modules=[
24
+ Extension("_jsonyx", ["src/jsonyx/_speedups.c"], optional=True),
25
+ ],
26
+ classifiers=[
27
+ "Development Status :: 5 - Production/Stable",
28
+ "Intended Audience :: Developers",
29
+ "Operating System :: OS Independent",
30
+ "Programming Language :: Python :: 3 :: Only",
31
+ "Programming Language :: Python :: 3.8",
32
+ "Programming Language :: Python :: 3.9",
33
+ "Programming Language :: Python :: 3.10",
34
+ "Programming Language :: Python :: 3.11",
35
+ "Programming Language :: Python :: 3.12",
36
+ "Programming Language :: Python :: 3.13",
37
+ "Programming Language :: Python :: 3.14",
38
+ ],
39
+ license="GPL-3.0",
40
+ keywords=["python", "json", "json-parser"],
41
+ package_dir={"": "src"},
42
+ # setuptools arguments
43
+ entry_points={"console_scripts": ["jsonyx = jsonyx.__main__:main"]},
44
+ python_requires=">=3.8",
45
+ project_urls={
46
+ "Homepage": "https://github.com/nineteendo/jsonyx",
47
+ "Changelog": (
48
+ "https://jsonyx.readthedocs.io/en/latest/changelog.html"
49
+ ),
50
+ "Documentation": "https://jsonyx.readthedocs.io",
51
+ "Issues": "https://github.com/nineteendo/jsonyx/issues",
52
+ "Sponser": "https://paypal.me/nineteendo",
53
+ },
54
+ )
@@ -21,7 +21,7 @@ __all__: list[str] = [
21
21
  "select_nodes",
22
22
  "write",
23
23
  ]
24
- __version__: str = "2.2.0"
24
+ __version__: str = "2.3.0"
25
25
 
26
26
  from typing import TYPE_CHECKING, Any, Protocol, TypeVar
27
27
 
@@ -135,7 +135,7 @@ def read(
135
135
  >>> with TemporaryDirectory() as tmpdir:
136
136
  ... filename = Path(tmpdir) / "file.json"
137
137
  ... _ = filename.write_text('["filesystem API"]', "utf-8")
138
- ... json.Decoder().read(filename)
138
+ ... json.read(filename)
139
139
  ...
140
140
  ['filesystem API']
141
141
 
@@ -186,7 +186,7 @@ def load(
186
186
 
187
187
 
188
188
  def loads(
189
- s: bytes | str,
189
+ s: bytearray | bytes | str,
190
190
  *,
191
191
  allow: Container[str] = NOTHING,
192
192
  cache_keys: bool = False,
@@ -242,7 +242,8 @@ def _run(args: _Namespace) -> None:
242
242
  stderr.write("".join(format_syntax_error(exc)))
243
243
  sys.exit(1)
244
244
  except (
245
- AssertionError, LookupError, RecursionError, TypeError, ValueError,
245
+ AssertionError, LookupError, OSError, RecursionError, TypeError,
246
+ ValueError,
246
247
  ) as exc:
247
248
  stderr.write("".join(format_exception_only(None, exc)))
248
249
  sys.exit(1)
@@ -124,7 +124,9 @@ def _unescape_unicode(filename: str, s: str, end: int) -> int:
124
124
 
125
125
 
126
126
  class TruncatedSyntaxError(SyntaxError):
127
- """Truncated syntax error.
127
+ """Syntax error trucated to fit within the terminal width.
128
+
129
+ .. versionadded:: 2.0
128
130
 
129
131
  :param msg: an error message
130
132
  :param filename: the path to the file
@@ -134,12 +136,17 @@ class TruncatedSyntaxError(SyntaxError):
134
136
 
135
137
  Example:
136
138
  >>> import jsonyx as json
137
- >>> raise json.TruncatedSyntaxError("Expecting value", "<string>", "[,]", 1)
139
+ >>> raise json.TruncatedSyntaxError(
140
+ ... "Invalid number", "<string>", "9" * 5000, 0, 5000
141
+ ... )
138
142
  Traceback (most recent call last):
139
- File "<string>", line 1, column 2
140
- [,]
141
- ^
142
- jsonyx.TruncatedSyntaxError: Expecting value
143
+ File "<string>", line 1, column 1-5001
144
+ 99999999999999999999999999999999999...9999999999999999999999999999999999
145
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
146
+ jsonyx.TruncatedSyntaxError: Invalid number
147
+
148
+ .. tip:: You can overwrite the width by setting the ``COLUMNS`` environment
149
+ variable.
143
150
 
144
151
  .. seealso:: :func:`jsonyx.format_syntax_error` for formatting the
145
152
  exception.
@@ -213,17 +220,14 @@ TruncatedSyntaxError.__module__ = "jsonyx"
213
220
 
214
221
 
215
222
  class JSONSyntaxError(TruncatedSyntaxError):
216
- """Invalid JSON (query) syntax.
217
-
218
- See :exc:`jsonyx.TruncatedSyntaxError` for more information.
219
- """
223
+ """Invalid JSON (query) syntax."""
220
224
 
221
225
 
222
226
  JSONSyntaxError.__module__ = "jsonyx"
223
227
  _errmsg: type[JSONSyntaxError] = JSONSyntaxError
224
228
 
225
229
 
226
- def detect_encoding(b: bytes) -> str:
230
+ def detect_encoding(b: bytearray | bytes) -> str:
227
231
  r"""Detect the JSON encoding.
228
232
 
229
233
  :param b: a JSON string
@@ -262,6 +266,7 @@ def detect_encoding(b: bytes) -> str:
262
266
  # XX 00 XX -- - utf-16-le
263
267
  encoding = "utf-16-le" if b[2] or b[3] else "utf-32-le"
264
268
  elif len(b) == 2:
269
+ # check for cut off json
265
270
  if not b[0]:
266
271
  # 00 -- - utf-16-be
267
272
  encoding = "utf-16-be"
@@ -679,10 +684,11 @@ class Decoder:
679
684
  >>> import jsonyx as json
680
685
  >>> from pathlib import Path
681
686
  >>> from tempfile import TemporaryDirectory
687
+ >>> decoder = json.Decoder()
682
688
  >>> with TemporaryDirectory() as tmpdir:
683
689
  ... filename = Path(tmpdir) / "file.json"
684
690
  ... _ = filename.write_text('["filesystem API"]', "utf-8")
685
- ... json.Decoder().read(filename)
691
+ ... decoder.read(filename)
686
692
  ...
687
693
  ['filesystem API']
688
694
 
@@ -718,7 +724,7 @@ class Decoder:
718
724
  return self.loads(fp.read())
719
725
 
720
726
  def loads(
721
- self, s: bytes | str, *, filename: _StrPath = "<string>",
727
+ self, s: bytearray | bytes | str, *, filename: _StrPath = "<string>",
722
728
  ) -> Any:
723
729
  r"""Deserialize a JSON string to a Python object.
724
730
 
@@ -78,16 +78,16 @@ def _make_patch(
78
78
  if isinstance(old, dict) and isinstance(new, dict):
79
79
  old_keys: KeysView[Any] = old.keys() # type: ignore
80
80
  new_keys: KeysView[Any] = new.keys() # type: ignore
81
- for key in old_keys:
82
- new_path: str = f"{path}{_encode_query_key(key)}"
81
+ for key in old_keys: # type: ignore
82
+ new_path: str = f"{path}{_encode_query_key(key)}" # type: ignore
83
83
  if key in new_keys:
84
84
  _make_patch(old[key], new[key], patch, new_path)
85
85
  else:
86
86
  patch.append({"op": "del", "path": new_path})
87
87
 
88
- for key in new_keys:
88
+ for key in new_keys: # type: ignore
89
89
  if key not in old_keys: # preserve order
90
- new_path = f"{path}{_encode_query_key(key)}"
90
+ new_path = f"{path}{_encode_query_key(key)}" # type: ignore
91
91
  patch.append(
92
92
  {"op": "set", "path": new_path, "value": new[key]},
93
93
  )
@@ -220,22 +220,20 @@ except ImportError:
220
220
  first: bool = True
221
221
  items: ItemsView[object, object] = mapping.items()
222
222
  for key, value in sorted(items) if sort_keys else items:
223
- new_key = hook(key)
224
- if isinstance(new_key, (str, str_types)):
225
- s = str(new_key)
223
+ key = hook(key) # noqa: PLW2901
224
+ if isinstance(key, (str, str_types)):
225
+ s = str(key)
226
226
  else:
227
- if new_key is None:
227
+ if key is None:
228
228
  s = "null"
229
- elif isinstance(new_key, (bool, bool_types)):
230
- s = "true" if new_key else "false"
231
- elif isinstance(new_key, (
232
- float, int, float_types, int_types,
233
- )):
234
- s = encode_float(new_key) # type: ignore
229
+ elif isinstance(key, (bool, bool_types)):
230
+ s = "true" if key else "false"
231
+ elif isinstance(key, (float, int, float_types, int_types)):
232
+ s = encode_float(key)
235
233
  elif skipkeys:
236
234
  continue
237
235
  else:
238
- msg = f"Keys must be str, not {type(new_key).__name__}"
236
+ msg = f"Keys must be str, not {type(key).__name__}"
239
237
  raise TypeError(msg)
240
238
 
241
239
  if not allow_non_str_keys:
@@ -287,7 +285,7 @@ except ImportError:
287
285
  elif isinstance(obj, (str, str_types)):
288
286
  write(encode_string(str(obj)))
289
287
  elif isinstance(obj, (float, int, float_types, int_types)):
290
- write(encode_float(obj)) # type: ignore
288
+ write(encode_float(obj))
291
289
  elif isinstance(obj, (list, tuple, array_types)):
292
290
  write_sequence(obj, write, indent_level, current_indent)
293
291
  elif isinstance(obj, (dict, object_types)):