gcf-python 2.2.1__tar.gz → 2.2.2__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 (36) hide show
  1. {gcf_python-2.2.1 → gcf_python-2.2.2}/CHANGELOG.md +10 -0
  2. {gcf_python-2.2.1 → gcf_python-2.2.2}/PKG-INFO +8 -4
  3. {gcf_python-2.2.1 → gcf_python-2.2.2}/README.md +7 -3
  4. {gcf_python-2.2.1 → gcf_python-2.2.2}/pyproject.toml +1 -1
  5. {gcf_python-2.2.1 → gcf_python-2.2.2}/src/gcf/__init__.py +1 -1
  6. {gcf_python-2.2.1 → gcf_python-2.2.2}/src/gcf/generic.py +11 -3
  7. {gcf_python-2.2.1 → gcf_python-2.2.2}/tests/test_roundtrip_v2.py +74 -0
  8. gcf_python-2.2.2/uv.lock +8 -0
  9. {gcf_python-2.2.1 → gcf_python-2.2.2}/.github/FUNDING.yml +0 -0
  10. {gcf_python-2.2.1 → gcf_python-2.2.2}/.github/workflows/ci.yml +0 -0
  11. {gcf_python-2.2.1 → gcf_python-2.2.2}/.github/workflows/publish.yml +0 -0
  12. {gcf_python-2.2.1 → gcf_python-2.2.2}/.gitignore +0 -0
  13. {gcf_python-2.2.1 → gcf_python-2.2.2}/LICENSE +0 -0
  14. {gcf_python-2.2.1 → gcf_python-2.2.2}/assets/gcf-python-diagram.png +0 -0
  15. {gcf_python-2.2.1 → gcf_python-2.2.2}/src/gcf/__main__.py +0 -0
  16. {gcf_python-2.2.1 → gcf_python-2.2.2}/src/gcf/cli.py +0 -0
  17. {gcf_python-2.2.1 → gcf_python-2.2.2}/src/gcf/constants.py +0 -0
  18. {gcf_python-2.2.1 → gcf_python-2.2.2}/src/gcf/decode.py +0 -0
  19. {gcf_python-2.2.1 → gcf_python-2.2.2}/src/gcf/decode_generic.py +0 -0
  20. {gcf_python-2.2.1 → gcf_python-2.2.2}/src/gcf/delta.py +0 -0
  21. {gcf_python-2.2.1 → gcf_python-2.2.2}/src/gcf/encode.py +0 -0
  22. {gcf_python-2.2.1 → gcf_python-2.2.2}/src/gcf/scalar.py +0 -0
  23. {gcf_python-2.2.1 → gcf_python-2.2.2}/src/gcf/session.py +0 -0
  24. {gcf_python-2.2.1 → gcf_python-2.2.2}/src/gcf/stream.py +0 -0
  25. {gcf_python-2.2.1 → gcf_python-2.2.2}/src/gcf/stream_generic.py +0 -0
  26. {gcf_python-2.2.1 → gcf_python-2.2.2}/src/gcf/types.py +0 -0
  27. {gcf_python-2.2.1 → gcf_python-2.2.2}/tests/__init__.py +0 -0
  28. {gcf_python-2.2.1 → gcf_python-2.2.2}/tests/test_conformance_v2.py +0 -0
  29. {gcf_python-2.2.1 → gcf_python-2.2.2}/tests/test_decode.py +0 -0
  30. {gcf_python-2.2.1 → gcf_python-2.2.2}/tests/test_delta.py +0 -0
  31. {gcf_python-2.2.1 → gcf_python-2.2.2}/tests/test_encode.py +0 -0
  32. {gcf_python-2.2.1 → gcf_python-2.2.2}/tests/test_generic.py +0 -0
  33. {gcf_python-2.2.1 → gcf_python-2.2.2}/tests/test_roundtrip.py +0 -0
  34. {gcf_python-2.2.1 → gcf_python-2.2.2}/tests/test_session.py +0 -0
  35. {gcf_python-2.2.1 → gcf_python-2.2.2}/tests/test_stream.py +0 -0
  36. {gcf_python-2.2.1 → gcf_python-2.2.2}/tests/test_stream_generic.py +0 -0
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## v2.2.2 (2026-07-10)
4
+
5
+ ### Fixes
6
+
7
+ - **Losslessness (nested null):** a nested object that is null at an intermediate level (e.g. `{"meta": {"owner": None}}`) is no longer flattened. Previously its leaves encoded as absent (`~`) and unflattened to a missing key, silently dropping the null. Such fields now fall back to the attachment mechanism; a top-level `None` still flattens losslessly (emits `-`, reconstructs via the all-null rule). Enforced by the shared conformance fixtures `flatten/017`–`019`. Prototype pollution does not affect Python (dicts have no mutable prototype).
8
+
9
+ ### Tests
10
+
11
+ - `test_flatten_roundtrip`: aligned arrays whose shared fields are fixed-shape nested objects with a field or an intermediate nested level sometimes null/absent — the shape the prior scalar-only generator never produced, leaving the flatten/unflatten path unexercised. Verified to fail on the pre-fix encoder and pass on the fix.
12
+
3
13
  ## v2.2.1 (2026-06-23)
4
14
 
5
15
  ### Flatten Opt-Out
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gcf-python
3
- Version: 2.2.1
3
+ Version: 2.2.2
4
4
  Summary: The AI-native wire format for structured data. 50-92% fewer tokens than JSON. 100% comprehension on every frontier model. Zero dependencies.
5
5
  Project-URL: Homepage, https://github.com/blackwell-systems/gcf-python
6
6
  Project-URL: Documentation, https://blackwell-systems.github.io/gcf/
@@ -32,7 +32,7 @@ Description-Content-Type: text/markdown
32
32
 
33
33
  Python implementation of [GCF](https://gcformat.com/) — the most token-efficient wire format for LLMs. A drop-in alternative to JSON and TOON for any structured data.
34
34
 
35
- **100% comprehension on every frontier model tested. 29% fewer tokens than TOON, 56% fewer than JSON across 16 datasets. 91.2% on structurally complex code graphs (vs TOON 68.2%, JSON 53.4%). 2,400+ LLM evaluations. Zero training.**
35
+ **100% comprehension on every frontier model tested. 29% fewer tokens than TOON, 56% fewer than JSON across 16 datasets. 91.2% on structurally complex code graphs (vs TOON 68.8%, JSON 54.1%). 2,400+ LLM evaluations. Zero training.**
36
36
 
37
37
  Docs: [gcformat.com](https://gcformat.com/) · [Playground](https://gcformat.com/playground.html) · [GCF vs TOON](https://gcformat.com/guide/vs-toon.html)
38
38
 
@@ -210,7 +210,7 @@ Works on dicts, lists, and primitives. Lists of uniform dicts get tabular rows.
210
210
 
211
211
  | | GCF | TOON | JSON |
212
212
  |---|---|---|---|
213
- | **Comprehension** (23 runs, 10 models) | **91.2%** | 68.2% | 53.4% |
213
+ | **Comprehension** (23 runs, 10 models) | **91.2%** | 68.8% | 54.1% |
214
214
  | **Generation** (28 runs, 9 models) | **5/5** | 1.0/5 | 5.0/5 |
215
215
  | **Input tokens** (500 symbols) | **11,090** | 16,378 | 53,341 |
216
216
  | **Output tokens** (100 symbols) | **5,976** | 8,937 | 16,121 |
@@ -236,7 +236,11 @@ GCF wins 15/16 datasets on the expanded [token efficiency benchmark](https://git
236
236
 
237
237
  **Zero runtime dependencies. Permanently.** All six implementations depend only on their language's standard library. No transitive dependencies. No supply chain risk. This is a permanent commitment: GCF will never take on external runtime dependencies. MIT licensed. All implementations support both generic profile (`encodeGeneric`) and graph profile (`encode`). CLI included in all 6 languages.
238
238
 
239
- **Specification:** [SPEC v3.2 Stable](https://github.com/blackwell-systems/gcf/blob/main/SPEC.md) with 173 conformance fixtures, 43,000,000,000+ lossless round-trips verified across 5 formats and 6 languages. All implementations at v2.2.0+ (Go v1.3.0). Cross-language 6x6 matrix verified.
239
+ **Specification:** [SPEC v3.2 Stable](https://github.com/blackwell-systems/gcf/blob/main/SPEC.md) with 174 conformance fixtures, 43,000,000,000+ lossless round-trips verified across 5 formats and 6 languages. All implementations at v2.2.1+ (Go v1.3.1). Cross-language 6x6 matrix verified.
240
+
241
+ ## Adopted by
242
+
243
+ [Chrome DevTools MCP](https://github.com/ChromeDevTools/chrome-devtools-mcp) (46K stars, Google Chrome DevTools team) · [Speakeasy](https://speakeasy.com) (API tooling, customers include Google, Verizon, Mistral AI, DocuSign, Vercel) · [OmniRoute](https://omniroute.online) (6.1K stars) · [NetClaw](https://github.com/automateyournetwork/netclaw) (556 stars) · [ctx](https://github.com/stevesolun/ctx) (510 stars) · [NeuroNest](https://neuronest.cc) · [Open Data Products SDK](https://opendataproducts.org/sdk/) (Linux Foundation) · [Raycast](https://raycast.com/blackwell-systems/json-to-gcf-converter) · [and more](https://gcformat.com/ecosystem/adopters.html)
240
244
 
241
245
  ## License
242
246
 
@@ -7,7 +7,7 @@
7
7
 
8
8
  Python implementation of [GCF](https://gcformat.com/) — the most token-efficient wire format for LLMs. A drop-in alternative to JSON and TOON for any structured data.
9
9
 
10
- **100% comprehension on every frontier model tested. 29% fewer tokens than TOON, 56% fewer than JSON across 16 datasets. 91.2% on structurally complex code graphs (vs TOON 68.2%, JSON 53.4%). 2,400+ LLM evaluations. Zero training.**
10
+ **100% comprehension on every frontier model tested. 29% fewer tokens than TOON, 56% fewer than JSON across 16 datasets. 91.2% on structurally complex code graphs (vs TOON 68.8%, JSON 54.1%). 2,400+ LLM evaluations. Zero training.**
11
11
 
12
12
  Docs: [gcformat.com](https://gcformat.com/) · [Playground](https://gcformat.com/playground.html) · [GCF vs TOON](https://gcformat.com/guide/vs-toon.html)
13
13
 
@@ -185,7 +185,7 @@ Works on dicts, lists, and primitives. Lists of uniform dicts get tabular rows.
185
185
 
186
186
  | | GCF | TOON | JSON |
187
187
  |---|---|---|---|
188
- | **Comprehension** (23 runs, 10 models) | **91.2%** | 68.2% | 53.4% |
188
+ | **Comprehension** (23 runs, 10 models) | **91.2%** | 68.8% | 54.1% |
189
189
  | **Generation** (28 runs, 9 models) | **5/5** | 1.0/5 | 5.0/5 |
190
190
  | **Input tokens** (500 symbols) | **11,090** | 16,378 | 53,341 |
191
191
  | **Output tokens** (100 symbols) | **5,976** | 8,937 | 16,121 |
@@ -211,7 +211,11 @@ GCF wins 15/16 datasets on the expanded [token efficiency benchmark](https://git
211
211
 
212
212
  **Zero runtime dependencies. Permanently.** All six implementations depend only on their language's standard library. No transitive dependencies. No supply chain risk. This is a permanent commitment: GCF will never take on external runtime dependencies. MIT licensed. All implementations support both generic profile (`encodeGeneric`) and graph profile (`encode`). CLI included in all 6 languages.
213
213
 
214
- **Specification:** [SPEC v3.2 Stable](https://github.com/blackwell-systems/gcf/blob/main/SPEC.md) with 173 conformance fixtures, 43,000,000,000+ lossless round-trips verified across 5 formats and 6 languages. All implementations at v2.2.0+ (Go v1.3.0). Cross-language 6x6 matrix verified.
214
+ **Specification:** [SPEC v3.2 Stable](https://github.com/blackwell-systems/gcf/blob/main/SPEC.md) with 174 conformance fixtures, 43,000,000,000+ lossless round-trips verified across 5 formats and 6 languages. All implementations at v2.2.1+ (Go v1.3.1). Cross-language 6x6 matrix verified.
215
+
216
+ ## Adopted by
217
+
218
+ [Chrome DevTools MCP](https://github.com/ChromeDevTools/chrome-devtools-mcp) (46K stars, Google Chrome DevTools team) · [Speakeasy](https://speakeasy.com) (API tooling, customers include Google, Verizon, Mistral AI, DocuSign, Vercel) · [OmniRoute](https://omniroute.online) (6.1K stars) · [NetClaw](https://github.com/automateyournetwork/netclaw) (556 stars) · [ctx](https://github.com/stevesolun/ctx) (510 stars) · [NeuroNest](https://neuronest.cc) · [Open Data Products SDK](https://opendataproducts.org/sdk/) (Linux Foundation) · [Raycast](https://raycast.com/blackwell-systems/json-to-gcf-converter) · [and more](https://gcformat.com/ecosystem/adopters.html)
215
219
 
216
220
  ## License
217
221
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "gcf-python"
7
- version = "2.2.1"
7
+ version = "2.2.2"
8
8
  description = "The AI-native wire format for structured data. 50-92% fewer tokens than JSON. 100% comprehension on every frontier model. Zero dependencies."
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -66,4 +66,4 @@ __all__ = [
66
66
  "encode_with_session",
67
67
  ]
68
68
 
69
- __version__ = "1.0.0"
69
+ __version__ = "2.2.2"
@@ -14,8 +14,8 @@ class GenericOptions:
14
14
  no_flatten: bool = False
15
15
  """When True, disables promotion of fixed-shape nested objects to path
16
16
  columns (e.g. "customer>name"). Nested objects use attachment syntax
17
- instead. Set when targeting open-weight models that show lower
18
- comprehension on flattened encoding."""
17
+ instead. Open-weight models currently comprehend the expanded form
18
+ better; this gap is expected to close."""
19
19
 
20
20
 
21
21
  def encode_generic(data: Any, opts: GenericOptions | None = None) -> str:
@@ -171,7 +171,15 @@ def _analyze_flattenable(
171
171
  canonical_shape: dict[str, str] | None = None # key -> "scalar" | "nested"
172
172
 
173
173
  for item in arr:
174
- if field_name not in item or item[field_name] is None:
174
+ if field_name not in item:
175
+ continue
176
+ # A nested (non-top-level) null cannot be flattened losslessly: its leaves
177
+ # would encode as absent ("~") and unflatten back to a missing key, not None.
178
+ # Bail to the attachment path. A top-level None is fine (emits "-" and
179
+ # reconstructs via the all-null rule), so just skip the row from shape analysis.
180
+ if item[field_name] is None:
181
+ if parent_path != "":
182
+ return None
175
183
  continue
176
184
  v = item[field_name]
177
185
  if not isinstance(v, dict):
@@ -214,6 +214,80 @@ def _structural_equal(a, b):
214
214
  return a == b
215
215
 
216
216
 
217
+ def _gen_flat_shape(r, depth, max_depth):
218
+ """A fixed nested schema: the string "scalar" or a dict of named sub-shapes."""
219
+ if depth >= max_depth or r.random() < 0.45:
220
+ return "scalar"
221
+ shape = {}
222
+ for _ in range(1 + r.randint(0, 2)):
223
+ shape[_gen_bare_key(r)] = _gen_flat_shape(r, depth + 1, max_depth)
224
+ return shape if shape else "scalar"
225
+
226
+
227
+ def _materialize_flat_shape(r, shape):
228
+ if shape == "scalar":
229
+ return _gen_scalar(r)
230
+ obj = {}
231
+ for k, s in shape.items():
232
+ # A nested sub-object is sometimes None (intermediate null — the case the
233
+ # pre-fix encoder dropped) instead of a full object.
234
+ obj[k] = None if s != "scalar" and r.random() < 0.3 else _materialize_flat_shape(r, s)
235
+ return obj
236
+
237
+
238
+ def _gen_flattenable_array(r):
239
+ schema = {"id": "scalar"}
240
+ order = ["id"]
241
+ has_nested = False
242
+ for _ in range(1 + r.randint(0, 2)):
243
+ k = _gen_bare_key(r)
244
+ if k in schema:
245
+ continue
246
+ s = _gen_flat_shape(r, 1, 3)
247
+ schema[k] = s
248
+ order.append(k)
249
+ if s != "scalar":
250
+ has_nested = True
251
+ if not has_nested:
252
+ k = _gen_bare_key(r)
253
+ schema[k] = {_gen_bare_key(r): {_gen_bare_key(r): "scalar"}}
254
+ order.append(k)
255
+ arr = []
256
+ for _ in range(2 + r.randint(0, 5)):
257
+ row = {}
258
+ for f in order:
259
+ x = r.random()
260
+ if x < 0.12:
261
+ continue # field absent this row
262
+ elif x < 0.24:
263
+ row[f] = None # field present-null (top-level null)
264
+ else:
265
+ row[f] = _materialize_flat_shape(r, schema[f])
266
+ arr.append(row)
267
+ return arr
268
+
269
+
270
+ def test_flatten_roundtrip():
271
+ """Aligned arrays whose shared fields are fixed-shape nested objects with a
272
+ field or an intermediate nested level sometimes null/absent — the v3.2 flatten
273
+ path the scalar-only generator never produces, so flatten/unflatten and its
274
+ null-at-depth losslessness edge would otherwise be unexercised."""
275
+ r = _rng(7)
276
+ for i in range(ITERATIONS):
277
+ val = _gen_flattenable_array(r)
278
+ for no_flatten in (False, True):
279
+ gcf = encode_generic(val, GenericOptions(no_flatten=no_flatten))
280
+ decoded = decode_generic(gcf)
281
+ a = _json_norm(val)
282
+ b = _json_norm(decoded)
283
+ assert _structural_equal(a, b), (
284
+ f"iteration {i} no_flatten={no_flatten}: round-trip mismatch\n"
285
+ f" input: {json.dumps(val)}\n"
286
+ f" decoded: {json.dumps(decoded)}\n"
287
+ f" gcf: {gcf!r}"
288
+ )
289
+
290
+
217
291
  def test_random_roundtrip():
218
292
  r = _rng(42)
219
293
  for i in range(ITERATIONS):
@@ -0,0 +1,8 @@
1
+ version = 1
2
+ revision = 3
3
+ requires-python = ">=3.9"
4
+
5
+ [[package]]
6
+ name = "gcf-python"
7
+ version = "2.0.0"
8
+ source = { editable = "." }
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