terset 0.2.3__tar.gz → 0.2.4__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.
- {terset-0.2.3/src/terset.egg-info → terset-0.2.4}/PKG-INFO +22 -17
- {terset-0.2.3 → terset-0.2.4}/README.md +21 -16
- {terset-0.2.3 → terset-0.2.4}/pyproject.toml +1 -1
- {terset-0.2.3 → terset-0.2.4/src/terset.egg-info}/PKG-INFO +22 -17
- {terset-0.2.3 → terset-0.2.4}/tests/test_decoder_errors.py +1 -1
- {terset-0.2.3 → terset-0.2.4}/tests/test_rules.py +1 -1
- {terset-0.2.3 → terset-0.2.4}/tests/test_terset.py +16 -5
- {terset-0.2.3 → terset-0.2.4}/LICENSE +0 -0
- {terset-0.2.3 → terset-0.2.4}/setup.cfg +0 -0
- {terset-0.2.3 → terset-0.2.4}/src/terset/__init__.py +0 -0
- {terset-0.2.3 → terset-0.2.4}/src/terset/_terset.py +0 -0
- {terset-0.2.3 → terset-0.2.4}/src/terset/py.typed +0 -0
- {terset-0.2.3 → terset-0.2.4}/src/terset.egg-info/SOURCES.txt +0 -0
- {terset-0.2.3 → terset-0.2.4}/src/terset.egg-info/dependency_links.txt +0 -0
- {terset-0.2.3 → terset-0.2.4}/src/terset.egg-info/top_level.txt +0 -0
- {terset-0.2.3 → terset-0.2.4}/tests/test_header_depth.py +0 -0
- {terset-0.2.3 → terset-0.2.4}/tests/test_header_performance.py +0 -0
- {terset-0.2.3 → terset-0.2.4}/tests/test_long_quoted.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: terset
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Encode JSON records as compact, typed tables.
|
|
5
5
|
Author: StackDeck
|
|
6
6
|
License-Expression: MIT
|
|
@@ -295,7 +295,7 @@ Where Terset does not win:
|
|
|
295
295
|
- o200k_base: Plain CSV is 9 to 88 tokens smaller on 2 flat, uniform lists, because it needs no rules line. It has no types, it merges null, absent and empty text, and it cannot hold nesting. On orders with line items it is larger: 4,769 vs 3,899.
|
|
296
296
|
- Claude: Plain CSV is 23 to 38 tokens smaller on 4 flat, uniform lists, because it needs no rules line. It has no types, it merges null, absent and empty text, and it cannot hold nesting. On orders with line items it is larger: 6,490 vs 5,662.
|
|
297
297
|
|
|
298
|
-
Across 1,000 seeds of the same 11 case shapes, counted with o200k_base, Terset wins or loses against JSON compact and TOON the same way on every seed.
|
|
298
|
+
Across 1,000 seeds of the same 11 case shapes, counted with o200k_base, Terset wins, ties or loses against JSON compact and TOON the same way on every seed.
|
|
299
299
|
|
|
300
300
|
Token counts say nothing about answer quality. Terset is about fewer tokens.
|
|
301
301
|
Other tokenizers and models will give other counts. Full benchmark with pretty JSON and CSV counts:
|
|
@@ -307,30 +307,33 @@ On 244 questions and two models, accuracy is a tie. Terset used fewer input toke
|
|
|
307
307
|
|
|
308
308
|
#### Claude Opus 5.5
|
|
309
309
|
|
|
310
|
-
| Format | Correct | Accuracy | 95% interval | Input tokens | Cost | Costs more than Terset | Run date |
|
|
311
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
312
|
-
| Terset |
|
|
313
|
-
| Compact JSON | 241 of 244 | 98.8% | 96.4% to 99.6% | 1,766,161 | $8.
|
|
314
|
-
| JSON |
|
|
315
|
-
| TOON |
|
|
310
|
+
| Format | Correct | Runs | Accuracy | 95% interval | Input tokens | Cost | Costs more than Terset | Run date |
|
|
311
|
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
312
|
+
| Terset | 243 of 244 | Mean of 3 runs: 243, 243, 243 | 99.6% | 97.7% to 99.9% | 1,188,659 | $5.65 | Reference | 2026-11-17 |
|
|
313
|
+
| Compact JSON | 241 of 244 | Mean of 3 runs: 241, 241, 241 | 98.8% | 96.4% to 99.6% | 1,766,161 | $8.05 | +42.4% | 2026-11-17 |
|
|
314
|
+
| JSON | 241 of 244 | Mean of 3 runs: 241, 241, 241 | 98.8% | 96.4% to 99.6% | 2,303,845 | $10.16 | +79.9% | 2026-11-17 |
|
|
315
|
+
| TOON | 241.7 of 244 | Mean of 3 runs: 242, 242, 241 (241 to 242) | 99.0% | 96.9% to 99.7% | 1,369,764 | $6.35 | +12.4% | 2026-11-17 |
|
|
316
316
|
|
|
317
317
|
#### GPT 6.1 Sol
|
|
318
318
|
|
|
319
|
-
| Format | Correct | Accuracy | 95% interval | Input tokens | Cost | Costs more than Terset | Run date |
|
|
320
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
321
|
-
| Terset | 242 of 244 | 99.2% | 97.1% to 99.8% | 842,260 | $1.84 | Reference | 2026-11-17 |
|
|
322
|
-
| Compact JSON |
|
|
323
|
-
| JSON | 237 of 244 | 97.
|
|
324
|
-
| TOON |
|
|
319
|
+
| Format | Correct | Runs | Accuracy | 95% interval | Input tokens | Cost | Costs more than Terset | Run date |
|
|
320
|
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
321
|
+
| Terset | 242 of 244 | Mean of 3 runs: 242, 241, 243 (241 to 243) | 99.2% | 97.1% to 99.8% | 842,260 | $1.84 | Reference | 2026-11-17 |
|
|
322
|
+
| Compact JSON | 235.3 of 244 | Mean of 3 runs: 236, 234, 236 (234 to 236) | 96.4% | 93.3% to 98.1% | 1,158,229 | $2.49 | +35.3% | 2026-11-17 |
|
|
323
|
+
| JSON | 237.3 of 244 | Mean of 3 runs: 237, 238, 237 (237 to 238) | 97.3% | 94.4% to 98.7% | 1,696,152 | $3.56 | +93.0% | 2026-11-17 |
|
|
324
|
+
| TOON | 242 of 244 | Mean of 3 runs: 242, 242, 242 | 99.2% | 97.1% to 99.8% | 1,020,628 | $2.20 | +19.2% | 2026-11-17 |
|
|
325
325
|
|
|
326
326
|
JSON is indented with 2 spaces. Compact JSON has no spaces or line breaks.
|
|
327
327
|
|
|
328
|
+
On both models, every format ran three times on 2026-11-17. Each model's runs are one matched batch with the same setup. No run is picked. Each row shows the mean of its runs, and the Runs column lists each run's score.
|
|
329
|
+
|
|
328
330
|
Accuracy is a tie. On 244 questions, every format's 95% interval overlaps every other format's, on both models.
|
|
329
|
-
|
|
331
|
+
One format's score moved by up to two questions from run to run. A gap that small is noise, not a win.
|
|
332
|
+
Against compact JSON, Terset cost 29.8% less on Claude Opus 5.5 and 26.1% less on GPT 6.1 Sol.
|
|
330
333
|
|
|
331
|
-
Cost is at API list price: input and output tokens times list prices read on 2026-11-
|
|
334
|
+
Cost is at API list price: input and output tokens times list prices read on 2026-11-17. Claude Opus 5.5 input tokens were counted with Anthropic's token counting endpoint over the exact request; GPT 6.1 Sol input tokens are as the model reported them. Temperature 0 where the model accepts it. Terset ran with fitted rules, which send only the rules each text needs. Each row names its run date.
|
|
332
335
|
|
|
333
|
-
Method and limits: [terset.dev/benchmark](https://terset.dev/benchmark#accuracy). Every answer and its score: [2026-11-12](https://github.com/stackdeckhq/terset/tree/main/bench/published/2026-11-12) and [2026-11-17](https://github.com/stackdeckhq/terset/tree/main/bench/published/2026-11-17).
|
|
336
|
+
Method and limits: [terset.dev/benchmark](https://terset.dev/benchmark#accuracy). Every answer and its score: [2026-11-12](https://github.com/stackdeckhq/terset/tree/main/bench/published/2026-11-12), [2026-11-13](https://github.com/stackdeckhq/terset/tree/main/bench/published/2026-11-13) and [2026-11-17](https://github.com/stackdeckhq/terset/tree/main/bench/published/2026-11-17).
|
|
334
337
|
|
|
335
338
|
## When not to use it
|
|
336
339
|
|
|
@@ -347,6 +350,8 @@ Method and limits: [terset.dev/benchmark](https://terset.dev/benchmark#accuracy)
|
|
|
347
350
|
|
|
348
351
|
<!-- docs:reference -->
|
|
349
352
|
Every function, parameter, error and limit, for JavaScript and Python: [terset.dev/docs](https://terset.dev/docs).
|
|
353
|
+
|
|
354
|
+
The format is frozen at 1.0. JavaScript and Python are separate implementations that both pass the conformance suite at conformance/ in the repository.
|
|
350
355
|
<!-- /docs:reference -->
|
|
351
356
|
|
|
352
357
|
## For agents
|
|
@@ -272,7 +272,7 @@ Where Terset does not win:
|
|
|
272
272
|
- o200k_base: Plain CSV is 9 to 88 tokens smaller on 2 flat, uniform lists, because it needs no rules line. It has no types, it merges null, absent and empty text, and it cannot hold nesting. On orders with line items it is larger: 4,769 vs 3,899.
|
|
273
273
|
- Claude: Plain CSV is 23 to 38 tokens smaller on 4 flat, uniform lists, because it needs no rules line. It has no types, it merges null, absent and empty text, and it cannot hold nesting. On orders with line items it is larger: 6,490 vs 5,662.
|
|
274
274
|
|
|
275
|
-
Across 1,000 seeds of the same 11 case shapes, counted with o200k_base, Terset wins or loses against JSON compact and TOON the same way on every seed.
|
|
275
|
+
Across 1,000 seeds of the same 11 case shapes, counted with o200k_base, Terset wins, ties or loses against JSON compact and TOON the same way on every seed.
|
|
276
276
|
|
|
277
277
|
Token counts say nothing about answer quality. Terset is about fewer tokens.
|
|
278
278
|
Other tokenizers and models will give other counts. Full benchmark with pretty JSON and CSV counts:
|
|
@@ -284,30 +284,33 @@ On 244 questions and two models, accuracy is a tie. Terset used fewer input toke
|
|
|
284
284
|
|
|
285
285
|
#### Claude Opus 5.5
|
|
286
286
|
|
|
287
|
-
| Format | Correct | Accuracy | 95% interval | Input tokens | Cost | Costs more than Terset | Run date |
|
|
288
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
289
|
-
| Terset |
|
|
290
|
-
| Compact JSON | 241 of 244 | 98.8% | 96.4% to 99.6% | 1,766,161 | $8.
|
|
291
|
-
| JSON |
|
|
292
|
-
| TOON |
|
|
287
|
+
| Format | Correct | Runs | Accuracy | 95% interval | Input tokens | Cost | Costs more than Terset | Run date |
|
|
288
|
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
289
|
+
| Terset | 243 of 244 | Mean of 3 runs: 243, 243, 243 | 99.6% | 97.7% to 99.9% | 1,188,659 | $5.65 | Reference | 2026-11-17 |
|
|
290
|
+
| Compact JSON | 241 of 244 | Mean of 3 runs: 241, 241, 241 | 98.8% | 96.4% to 99.6% | 1,766,161 | $8.05 | +42.4% | 2026-11-17 |
|
|
291
|
+
| JSON | 241 of 244 | Mean of 3 runs: 241, 241, 241 | 98.8% | 96.4% to 99.6% | 2,303,845 | $10.16 | +79.9% | 2026-11-17 |
|
|
292
|
+
| TOON | 241.7 of 244 | Mean of 3 runs: 242, 242, 241 (241 to 242) | 99.0% | 96.9% to 99.7% | 1,369,764 | $6.35 | +12.4% | 2026-11-17 |
|
|
293
293
|
|
|
294
294
|
#### GPT 6.1 Sol
|
|
295
295
|
|
|
296
|
-
| Format | Correct | Accuracy | 95% interval | Input tokens | Cost | Costs more than Terset | Run date |
|
|
297
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
298
|
-
| Terset | 242 of 244 | 99.2% | 97.1% to 99.8% | 842,260 | $1.84 | Reference | 2026-11-17 |
|
|
299
|
-
| Compact JSON |
|
|
300
|
-
| JSON | 237 of 244 | 97.
|
|
301
|
-
| TOON |
|
|
296
|
+
| Format | Correct | Runs | Accuracy | 95% interval | Input tokens | Cost | Costs more than Terset | Run date |
|
|
297
|
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
298
|
+
| Terset | 242 of 244 | Mean of 3 runs: 242, 241, 243 (241 to 243) | 99.2% | 97.1% to 99.8% | 842,260 | $1.84 | Reference | 2026-11-17 |
|
|
299
|
+
| Compact JSON | 235.3 of 244 | Mean of 3 runs: 236, 234, 236 (234 to 236) | 96.4% | 93.3% to 98.1% | 1,158,229 | $2.49 | +35.3% | 2026-11-17 |
|
|
300
|
+
| JSON | 237.3 of 244 | Mean of 3 runs: 237, 238, 237 (237 to 238) | 97.3% | 94.4% to 98.7% | 1,696,152 | $3.56 | +93.0% | 2026-11-17 |
|
|
301
|
+
| TOON | 242 of 244 | Mean of 3 runs: 242, 242, 242 | 99.2% | 97.1% to 99.8% | 1,020,628 | $2.20 | +19.2% | 2026-11-17 |
|
|
302
302
|
|
|
303
303
|
JSON is indented with 2 spaces. Compact JSON has no spaces or line breaks.
|
|
304
304
|
|
|
305
|
+
On both models, every format ran three times on 2026-11-17. Each model's runs are one matched batch with the same setup. No run is picked. Each row shows the mean of its runs, and the Runs column lists each run's score.
|
|
306
|
+
|
|
305
307
|
Accuracy is a tie. On 244 questions, every format's 95% interval overlaps every other format's, on both models.
|
|
306
|
-
|
|
308
|
+
One format's score moved by up to two questions from run to run. A gap that small is noise, not a win.
|
|
309
|
+
Against compact JSON, Terset cost 29.8% less on Claude Opus 5.5 and 26.1% less on GPT 6.1 Sol.
|
|
307
310
|
|
|
308
|
-
Cost is at API list price: input and output tokens times list prices read on 2026-11-
|
|
311
|
+
Cost is at API list price: input and output tokens times list prices read on 2026-11-17. Claude Opus 5.5 input tokens were counted with Anthropic's token counting endpoint over the exact request; GPT 6.1 Sol input tokens are as the model reported them. Temperature 0 where the model accepts it. Terset ran with fitted rules, which send only the rules each text needs. Each row names its run date.
|
|
309
312
|
|
|
310
|
-
Method and limits: [terset.dev/benchmark](https://terset.dev/benchmark#accuracy). Every answer and its score: [2026-11-12](https://github.com/stackdeckhq/terset/tree/main/bench/published/2026-11-12) and [2026-11-17](https://github.com/stackdeckhq/terset/tree/main/bench/published/2026-11-17).
|
|
313
|
+
Method and limits: [terset.dev/benchmark](https://terset.dev/benchmark#accuracy). Every answer and its score: [2026-11-12](https://github.com/stackdeckhq/terset/tree/main/bench/published/2026-11-12), [2026-11-13](https://github.com/stackdeckhq/terset/tree/main/bench/published/2026-11-13) and [2026-11-17](https://github.com/stackdeckhq/terset/tree/main/bench/published/2026-11-17).
|
|
311
314
|
|
|
312
315
|
## When not to use it
|
|
313
316
|
|
|
@@ -324,6 +327,8 @@ Method and limits: [terset.dev/benchmark](https://terset.dev/benchmark#accuracy)
|
|
|
324
327
|
|
|
325
328
|
<!-- docs:reference -->
|
|
326
329
|
Every function, parameter, error and limit, for JavaScript and Python: [terset.dev/docs](https://terset.dev/docs).
|
|
330
|
+
|
|
331
|
+
The format is frozen at 1.0. JavaScript and Python are separate implementations that both pass the conformance suite at conformance/ in the repository.
|
|
327
332
|
<!-- /docs:reference -->
|
|
328
333
|
|
|
329
334
|
## For agents
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: terset
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Encode JSON records as compact, typed tables.
|
|
5
5
|
Author: StackDeck
|
|
6
6
|
License-Expression: MIT
|
|
@@ -295,7 +295,7 @@ Where Terset does not win:
|
|
|
295
295
|
- o200k_base: Plain CSV is 9 to 88 tokens smaller on 2 flat, uniform lists, because it needs no rules line. It has no types, it merges null, absent and empty text, and it cannot hold nesting. On orders with line items it is larger: 4,769 vs 3,899.
|
|
296
296
|
- Claude: Plain CSV is 23 to 38 tokens smaller on 4 flat, uniform lists, because it needs no rules line. It has no types, it merges null, absent and empty text, and it cannot hold nesting. On orders with line items it is larger: 6,490 vs 5,662.
|
|
297
297
|
|
|
298
|
-
Across 1,000 seeds of the same 11 case shapes, counted with o200k_base, Terset wins or loses against JSON compact and TOON the same way on every seed.
|
|
298
|
+
Across 1,000 seeds of the same 11 case shapes, counted with o200k_base, Terset wins, ties or loses against JSON compact and TOON the same way on every seed.
|
|
299
299
|
|
|
300
300
|
Token counts say nothing about answer quality. Terset is about fewer tokens.
|
|
301
301
|
Other tokenizers and models will give other counts. Full benchmark with pretty JSON and CSV counts:
|
|
@@ -307,30 +307,33 @@ On 244 questions and two models, accuracy is a tie. Terset used fewer input toke
|
|
|
307
307
|
|
|
308
308
|
#### Claude Opus 5.5
|
|
309
309
|
|
|
310
|
-
| Format | Correct | Accuracy | 95% interval | Input tokens | Cost | Costs more than Terset | Run date |
|
|
311
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
312
|
-
| Terset |
|
|
313
|
-
| Compact JSON | 241 of 244 | 98.8% | 96.4% to 99.6% | 1,766,161 | $8.
|
|
314
|
-
| JSON |
|
|
315
|
-
| TOON |
|
|
310
|
+
| Format | Correct | Runs | Accuracy | 95% interval | Input tokens | Cost | Costs more than Terset | Run date |
|
|
311
|
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
312
|
+
| Terset | 243 of 244 | Mean of 3 runs: 243, 243, 243 | 99.6% | 97.7% to 99.9% | 1,188,659 | $5.65 | Reference | 2026-11-17 |
|
|
313
|
+
| Compact JSON | 241 of 244 | Mean of 3 runs: 241, 241, 241 | 98.8% | 96.4% to 99.6% | 1,766,161 | $8.05 | +42.4% | 2026-11-17 |
|
|
314
|
+
| JSON | 241 of 244 | Mean of 3 runs: 241, 241, 241 | 98.8% | 96.4% to 99.6% | 2,303,845 | $10.16 | +79.9% | 2026-11-17 |
|
|
315
|
+
| TOON | 241.7 of 244 | Mean of 3 runs: 242, 242, 241 (241 to 242) | 99.0% | 96.9% to 99.7% | 1,369,764 | $6.35 | +12.4% | 2026-11-17 |
|
|
316
316
|
|
|
317
317
|
#### GPT 6.1 Sol
|
|
318
318
|
|
|
319
|
-
| Format | Correct | Accuracy | 95% interval | Input tokens | Cost | Costs more than Terset | Run date |
|
|
320
|
-
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
321
|
-
| Terset | 242 of 244 | 99.2% | 97.1% to 99.8% | 842,260 | $1.84 | Reference | 2026-11-17 |
|
|
322
|
-
| Compact JSON |
|
|
323
|
-
| JSON | 237 of 244 | 97.
|
|
324
|
-
| TOON |
|
|
319
|
+
| Format | Correct | Runs | Accuracy | 95% interval | Input tokens | Cost | Costs more than Terset | Run date |
|
|
320
|
+
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
321
|
+
| Terset | 242 of 244 | Mean of 3 runs: 242, 241, 243 (241 to 243) | 99.2% | 97.1% to 99.8% | 842,260 | $1.84 | Reference | 2026-11-17 |
|
|
322
|
+
| Compact JSON | 235.3 of 244 | Mean of 3 runs: 236, 234, 236 (234 to 236) | 96.4% | 93.3% to 98.1% | 1,158,229 | $2.49 | +35.3% | 2026-11-17 |
|
|
323
|
+
| JSON | 237.3 of 244 | Mean of 3 runs: 237, 238, 237 (237 to 238) | 97.3% | 94.4% to 98.7% | 1,696,152 | $3.56 | +93.0% | 2026-11-17 |
|
|
324
|
+
| TOON | 242 of 244 | Mean of 3 runs: 242, 242, 242 | 99.2% | 97.1% to 99.8% | 1,020,628 | $2.20 | +19.2% | 2026-11-17 |
|
|
325
325
|
|
|
326
326
|
JSON is indented with 2 spaces. Compact JSON has no spaces or line breaks.
|
|
327
327
|
|
|
328
|
+
On both models, every format ran three times on 2026-11-17. Each model's runs are one matched batch with the same setup. No run is picked. Each row shows the mean of its runs, and the Runs column lists each run's score.
|
|
329
|
+
|
|
328
330
|
Accuracy is a tie. On 244 questions, every format's 95% interval overlaps every other format's, on both models.
|
|
329
|
-
|
|
331
|
+
One format's score moved by up to two questions from run to run. A gap that small is noise, not a win.
|
|
332
|
+
Against compact JSON, Terset cost 29.8% less on Claude Opus 5.5 and 26.1% less on GPT 6.1 Sol.
|
|
330
333
|
|
|
331
|
-
Cost is at API list price: input and output tokens times list prices read on 2026-11-
|
|
334
|
+
Cost is at API list price: input and output tokens times list prices read on 2026-11-17. Claude Opus 5.5 input tokens were counted with Anthropic's token counting endpoint over the exact request; GPT 6.1 Sol input tokens are as the model reported them. Temperature 0 where the model accepts it. Terset ran with fitted rules, which send only the rules each text needs. Each row names its run date.
|
|
332
335
|
|
|
333
|
-
Method and limits: [terset.dev/benchmark](https://terset.dev/benchmark#accuracy). Every answer and its score: [2026-11-12](https://github.com/stackdeckhq/terset/tree/main/bench/published/2026-11-12) and [2026-11-17](https://github.com/stackdeckhq/terset/tree/main/bench/published/2026-11-17).
|
|
336
|
+
Method and limits: [terset.dev/benchmark](https://terset.dev/benchmark#accuracy). Every answer and its score: [2026-11-12](https://github.com/stackdeckhq/terset/tree/main/bench/published/2026-11-12), [2026-11-13](https://github.com/stackdeckhq/terset/tree/main/bench/published/2026-11-13) and [2026-11-17](https://github.com/stackdeckhq/terset/tree/main/bench/published/2026-11-17).
|
|
334
337
|
|
|
335
338
|
## When not to use it
|
|
336
339
|
|
|
@@ -347,6 +350,8 @@ Method and limits: [terset.dev/benchmark](https://terset.dev/benchmark#accuracy)
|
|
|
347
350
|
|
|
348
351
|
<!-- docs:reference -->
|
|
349
352
|
Every function, parameter, error and limit, for JavaScript and Python: [terset.dev/docs](https://terset.dev/docs).
|
|
353
|
+
|
|
354
|
+
The format is frozen at 1.0. JavaScript and Python are separate implementations that both pass the conformance suite at conformance/ in the repository.
|
|
350
355
|
<!-- /docs:reference -->
|
|
351
356
|
|
|
352
357
|
## For agents
|
|
@@ -13,7 +13,7 @@ from terset import decode, encode
|
|
|
13
13
|
|
|
14
14
|
class DecoderErrorTests(unittest.TestCase):
|
|
15
15
|
def test_specific_errors(self):
|
|
16
|
-
cases = json.loads((PACKAGE.
|
|
16
|
+
cases = json.loads((PACKAGE.parents[1] / "conformance/rejection-errors.json").read_text(encoding="utf-8"))
|
|
17
17
|
for case in cases:
|
|
18
18
|
with self.subTest(case=case["name"]), self.assertRaises(ValueError) as caught:
|
|
19
19
|
decode(case["text"])
|
|
@@ -27,7 +27,7 @@ class RulesTests(unittest.TestCase):
|
|
|
27
27
|
self.assertEqual(cases[-1]["rules"], RULES)
|
|
28
28
|
|
|
29
29
|
def test_same_rejections(self):
|
|
30
|
-
cases = json.loads((PACKAGE.
|
|
30
|
+
cases = json.loads((PACKAGE.parents[1] / "conformance/rejection-errors.json").read_text(encoding="utf-8"))
|
|
31
31
|
cases.append({"text": "{2}\n@key\tname\na\tAda\nb\tLin"})
|
|
32
32
|
for case in cases:
|
|
33
33
|
with self.subTest(text=case["text"]):
|
|
@@ -9,6 +9,7 @@ import sys
|
|
|
9
9
|
import unittest
|
|
10
10
|
|
|
11
11
|
PACKAGE = Path(__file__).resolve().parents[1]
|
|
12
|
+
CONFORMANCE = PACKAGE.parents[1] / "conformance"
|
|
12
13
|
sys.path.insert(0, str(PACKAGE / "src"))
|
|
13
14
|
|
|
14
15
|
from terset import RULES, decode, encode # noqa: E402
|
|
@@ -42,6 +43,16 @@ def expand_case(case):
|
|
|
42
43
|
|
|
43
44
|
|
|
44
45
|
class ConformanceTests(unittest.TestCase):
|
|
46
|
+
def assert_value_and_key_order(self, actual, expected):
|
|
47
|
+
self.assertEqual(actual, expected)
|
|
48
|
+
if isinstance(expected, dict):
|
|
49
|
+
self.assertEqual(list(actual), list(expected))
|
|
50
|
+
for key in expected:
|
|
51
|
+
self.assert_value_and_key_order(actual[key], expected[key])
|
|
52
|
+
elif isinstance(expected, list):
|
|
53
|
+
for actual_item, expected_item in zip(actual, expected):
|
|
54
|
+
self.assert_value_and_key_order(actual_item, expected_item)
|
|
55
|
+
|
|
45
56
|
def test_counted_tables(self):
|
|
46
57
|
value = {"people": [{"name": "Ada"}, {"name": "Lin"}]}
|
|
47
58
|
text = "people[2]:\nname\nAda\nLin"
|
|
@@ -59,16 +70,16 @@ class ConformanceTests(unittest.TestCase):
|
|
|
59
70
|
def test_shared_cases(self):
|
|
60
71
|
# Fixture numbers describe JavaScript values. Parse them as binary64,
|
|
61
72
|
# including integral decimal tokens outside Python's exact-int range.
|
|
62
|
-
cases = json.loads((
|
|
73
|
+
cases = json.loads((CONFORMANCE / "cases.json").read_text(encoding="utf-8"), parse_int=float)
|
|
63
74
|
for case in cases:
|
|
64
75
|
with self.subTest(case=case["name"]):
|
|
65
76
|
value, encoded = expand_case(case)
|
|
66
77
|
self.assertEqual(encode(value), encoded)
|
|
67
|
-
self.
|
|
78
|
+
self.assert_value_and_key_order(decode(encoded), value)
|
|
68
79
|
self.assertEqual(encode(decode(encoded)), encoded)
|
|
69
80
|
|
|
70
81
|
def test_shared_integer_inputs(self):
|
|
71
|
-
cases = json.loads((
|
|
82
|
+
cases = json.loads((CONFORMANCE / "cases.json").read_text(encoding="utf-8"), parse_int=fixture_integer)
|
|
72
83
|
boundary = next(case for case in cases if case["name"] == "number formatting boundaries")
|
|
73
84
|
self.assertIs(type(boundary["input"]["values"][0]), int)
|
|
74
85
|
self.assertIs(type(boundary["input"]["values"][3]), int)
|
|
@@ -76,7 +87,7 @@ class ConformanceTests(unittest.TestCase):
|
|
|
76
87
|
with self.subTest(case=case["name"]):
|
|
77
88
|
value, encoded = expand_case(case)
|
|
78
89
|
self.assertEqual(encode(value), encoded)
|
|
79
|
-
self.
|
|
90
|
+
self.assert_value_and_key_order(decode(encoded), value)
|
|
80
91
|
|
|
81
92
|
def test_equal_size_fallback(self):
|
|
82
93
|
rows = [{"a": 1}, {"b": 1}, {"c": 1}, {"d": 1}, {"e": 1}, {}]
|
|
@@ -175,7 +186,7 @@ class ConformanceTests(unittest.TestCase):
|
|
|
175
186
|
self.assertEqual(decode("x: (()=>7)()"), {"x": "(()=>7)()"})
|
|
176
187
|
|
|
177
188
|
def test_shared_rejections(self):
|
|
178
|
-
texts = json.loads((
|
|
189
|
+
texts = json.loads((CONFORMANCE / "rejections.json").read_text(encoding="utf-8"))
|
|
179
190
|
for text in texts:
|
|
180
191
|
with self.subTest(text=text), self.assertRaises(ValueError):
|
|
181
192
|
decode(text)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|