gcf-python 0.1.1__tar.gz → 0.1.3__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 (24) hide show
  1. {gcf_python-0.1.1 → gcf_python-0.1.3}/CHANGELOG.md +5 -0
  2. {gcf_python-0.1.1 → gcf_python-0.1.3}/PKG-INFO +15 -8
  3. {gcf_python-0.1.1 → gcf_python-0.1.3}/README.md +14 -7
  4. {gcf_python-0.1.1 → gcf_python-0.1.3}/pyproject.toml +1 -1
  5. {gcf_python-0.1.1 → gcf_python-0.1.3}/src/gcf/__init__.py +1 -1
  6. {gcf_python-0.1.1 → gcf_python-0.1.3}/src/gcf/generic.py +10 -8
  7. {gcf_python-0.1.1 → gcf_python-0.1.3}/tests/test_generic.py +2 -2
  8. {gcf_python-0.1.1 → gcf_python-0.1.3}/.github/workflows/ci.yml +0 -0
  9. {gcf_python-0.1.1 → gcf_python-0.1.3}/.github/workflows/publish.yml +0 -0
  10. {gcf_python-0.1.1 → gcf_python-0.1.3}/.gitignore +0 -0
  11. {gcf_python-0.1.1 → gcf_python-0.1.3}/LICENSE +0 -0
  12. {gcf_python-0.1.1 → gcf_python-0.1.3}/src/gcf/cli.py +0 -0
  13. {gcf_python-0.1.1 → gcf_python-0.1.3}/src/gcf/constants.py +0 -0
  14. {gcf_python-0.1.1 → gcf_python-0.1.3}/src/gcf/decode.py +0 -0
  15. {gcf_python-0.1.1 → gcf_python-0.1.3}/src/gcf/delta.py +0 -0
  16. {gcf_python-0.1.1 → gcf_python-0.1.3}/src/gcf/encode.py +0 -0
  17. {gcf_python-0.1.1 → gcf_python-0.1.3}/src/gcf/session.py +0 -0
  18. {gcf_python-0.1.1 → gcf_python-0.1.3}/src/gcf/types.py +0 -0
  19. {gcf_python-0.1.1 → gcf_python-0.1.3}/tests/__init__.py +0 -0
  20. {gcf_python-0.1.1 → gcf_python-0.1.3}/tests/test_decode.py +0 -0
  21. {gcf_python-0.1.1 → gcf_python-0.1.3}/tests/test_delta.py +0 -0
  22. {gcf_python-0.1.1 → gcf_python-0.1.3}/tests/test_encode.py +0 -0
  23. {gcf_python-0.1.1 → gcf_python-0.1.3}/tests/test_roundtrip.py +0 -0
  24. {gcf_python-0.1.1 → gcf_python-0.1.3}/tests/test_session.py +0 -0
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.1.2 (2026-06-04)
4
+
5
+ - Fix: escape `"` inside quoted strings in `encode_generic`
6
+ - Fix: quote empty strings as `""` per spec
7
+
3
8
  ## v0.1.1 (2026-06-03)
4
9
 
5
10
  - `encode_generic`: encode arbitrary Python values into GCF tabular format
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gcf-python
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: Python implementation of GCF (Graph Compact Format): token-optimized wire format for LLM tool responses
5
5
  Project-URL: Homepage, https://github.com/blackwell-systems/gcf-python
6
6
  Project-URL: Documentation, https://blackwell-systems.github.io/gcf/
@@ -30,9 +30,11 @@ Description-Content-Type: text/markdown
30
30
 
31
31
  # gcf-python
32
32
 
33
- Python implementation of [GCF (Graph Compact Format)](https://github.com/blackwell-systems/gcf).
33
+ Python implementation of [GCF (Graph Compact Format)](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
- **84% fewer tokens than JSON. 32% fewer than TOON. 100% LLM comprehension accuracy at 500 symbols, where JSON fails.**
35
+ **79% fewer input tokens than JSON. 75% fewer output tokens. 52% smaller than TOON. 100% LLM comprehension at 500 symbols, where JSON fails at 66.7%.**
36
+
37
+ Docs: [gcformat.com](https://gcformat.com/) · [Playground](https://gcformat.com/playground.html) · [GCF vs TOON](https://gcformat.com/guide/vs-toon.html)
36
38
 
37
39
  ## Install
38
40
 
@@ -40,7 +42,7 @@ Python implementation of [GCF (Graph Compact Format)](https://github.com/blackwe
40
42
  pip install gcf-python
41
43
  ```
42
44
 
43
- Zero dependencies. Pure Python. Python 3.9+. Includes CLI.
45
+ Zero dependencies. Pure Python. Python 3.9+. Includes CLI. Don't want to change code? Use the [MCP proxy](https://github.com/blackwell-systems/gcf-proxy) for zero-code adoption.
44
46
 
45
47
  ## CLI
46
48
 
@@ -211,11 +213,16 @@ GCF wins on every dataset except deeply nested config (75 tokens on a 618-token
211
213
 
212
214
  Reproducible: [blackwell-systems/toon@gcf-comparison](https://github.com/blackwell-systems/toon/tree/gcf-comparison)
213
215
 
214
- ## Other Implementations
216
+ ## Links
215
217
 
216
- - **Go**: [github.com/blackwell-systems/gcf-go](https://github.com/blackwell-systems/gcf-go)
217
- - **TypeScript**: [github.com/blackwell-systems/gcf-typescript](https://github.com/blackwell-systems/gcf-typescript)
218
- - **Specification**: [github.com/blackwell-systems/gcf](https://github.com/blackwell-systems/gcf)
218
+ - [Documentation](https://gcformat.com/)
219
+ - [Playground](https://gcformat.com/playground.html)
220
+ - [Specification](https://github.com/blackwell-systems/gcf)
221
+ - [Go library](https://github.com/blackwell-systems/gcf-go)
222
+ - [TypeScript library](https://github.com/blackwell-systems/gcf-typescript)
223
+ - [MCP Proxy](https://github.com/blackwell-systems/gcf-proxy) (zero-code adoption)
224
+ - [GCF vs TOON](https://gcformat.com/guide/vs-toon.html)
225
+ - [TOON benchmark fork](https://github.com/blackwell-systems/toon/tree/gcf-comparison)
219
226
 
220
227
  ## License
221
228
 
@@ -5,9 +5,11 @@
5
5
 
6
6
  # gcf-python
7
7
 
8
- Python implementation of [GCF (Graph Compact Format)](https://github.com/blackwell-systems/gcf).
8
+ Python implementation of [GCF (Graph Compact Format)](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
- **84% fewer tokens than JSON. 32% fewer than TOON. 100% LLM comprehension accuracy at 500 symbols, where JSON fails.**
10
+ **79% fewer input tokens than JSON. 75% fewer output tokens. 52% smaller than TOON. 100% LLM comprehension at 500 symbols, where JSON fails at 66.7%.**
11
+
12
+ Docs: [gcformat.com](https://gcformat.com/) · [Playground](https://gcformat.com/playground.html) · [GCF vs TOON](https://gcformat.com/guide/vs-toon.html)
11
13
 
12
14
  ## Install
13
15
 
@@ -15,7 +17,7 @@ Python implementation of [GCF (Graph Compact Format)](https://github.com/blackwe
15
17
  pip install gcf-python
16
18
  ```
17
19
 
18
- Zero dependencies. Pure Python. Python 3.9+. Includes CLI.
20
+ Zero dependencies. Pure Python. Python 3.9+. Includes CLI. Don't want to change code? Use the [MCP proxy](https://github.com/blackwell-systems/gcf-proxy) for zero-code adoption.
19
21
 
20
22
  ## CLI
21
23
 
@@ -186,11 +188,16 @@ GCF wins on every dataset except deeply nested config (75 tokens on a 618-token
186
188
 
187
189
  Reproducible: [blackwell-systems/toon@gcf-comparison](https://github.com/blackwell-systems/toon/tree/gcf-comparison)
188
190
 
189
- ## Other Implementations
191
+ ## Links
190
192
 
191
- - **Go**: [github.com/blackwell-systems/gcf-go](https://github.com/blackwell-systems/gcf-go)
192
- - **TypeScript**: [github.com/blackwell-systems/gcf-typescript](https://github.com/blackwell-systems/gcf-typescript)
193
- - **Specification**: [github.com/blackwell-systems/gcf](https://github.com/blackwell-systems/gcf)
193
+ - [Documentation](https://gcformat.com/)
194
+ - [Playground](https://gcformat.com/playground.html)
195
+ - [Specification](https://github.com/blackwell-systems/gcf)
196
+ - [Go library](https://github.com/blackwell-systems/gcf-go)
197
+ - [TypeScript library](https://github.com/blackwell-systems/gcf-typescript)
198
+ - [MCP Proxy](https://github.com/blackwell-systems/gcf-proxy) (zero-code adoption)
199
+ - [GCF vs TOON](https://gcformat.com/guide/vs-toon.html)
200
+ - [TOON benchmark fork](https://github.com/blackwell-systems/toon/tree/gcf-comparison)
194
201
 
195
202
  ## License
196
203
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "gcf-python"
7
- version = "0.1.1"
7
+ version = "0.1.3"
8
8
  description = "Python implementation of GCF (Graph Compact Format): token-optimized wire format for LLM tool responses"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -59,4 +59,4 @@ __all__ = [
59
59
  "encode_with_session",
60
60
  ]
61
61
 
62
- __version__ = "0.1.1"
62
+ __version__ = "0.1.3"
@@ -18,6 +18,8 @@ def encode_generic(data: Any) -> str:
18
18
  Returns:
19
19
  GCF-formatted text string.
20
20
  """
21
+ if data is None or not isinstance(data, (dict, list)):
22
+ return str(data) if data is not None else "-"
21
23
  lines: list[str] = []
22
24
  _encode_value(data, lines, depth=0)
23
25
  return "\n".join(lines) + "\n" if lines else "\n"
@@ -33,15 +35,16 @@ def _encode_value(value: Any, lines: list[str], depth: int) -> None:
33
35
  lines.append(_indent(depth) + _format_value(value))
34
36
 
35
37
 
36
- def _encode_dict(d: dict, lines: list[str], depth: int) -> None:
38
+ def _encode_dict(d: dict, lines: list[str], depth: int, name: str | None = None) -> None:
37
39
  """Encode a dict into key=value pairs with section headers for nested values."""
38
40
  prefix = _indent(depth)
41
+ if name is not None:
42
+ lines.append(f"{prefix}## {name}")
39
43
  for key, value in d.items():
40
44
  if isinstance(value, list):
41
45
  _encode_array(value, key, lines, depth)
42
46
  elif isinstance(value, dict):
43
- lines.append(f"{prefix}## {key}")
44
- _encode_dict(value, lines, depth + 1)
47
+ _encode_dict(value, lines, depth + 1, name=key)
45
48
  else:
46
49
  lines.append(f"{prefix}{key}={_format_value(value)}")
47
50
 
@@ -85,14 +88,12 @@ def _encode_tabular(items: list[dict], name: str, lines: list[str], depth: int)
85
88
 
86
89
  if nested_fields:
87
90
  lines.append(f"{prefix}@{i} {row_str}")
88
- inner_prefix = _indent(depth + 1)
89
91
  for nk in nested_fields:
90
92
  nv = item.get(nk)
91
93
  if isinstance(nv, list):
92
94
  _encode_array(nv, nk, lines, depth + 1)
93
95
  elif isinstance(nv, dict):
94
- lines.append(f"{inner_prefix}## {nk}")
95
- _encode_dict(nv, lines, depth + 2)
96
+ _encode_dict(nv, lines, depth + 1, name=nk)
96
97
  else:
97
98
  lines.append(f"{prefix}{row_str}")
98
99
 
@@ -140,8 +141,9 @@ def _format_value(value: Any) -> str:
140
141
  if isinstance(value, (int, float)):
141
142
  return str(value)
142
143
  s = str(value)
143
- if "|" in s or "\n" in s:
144
- return f'"{s}"'
144
+ if "|" in s or "\n" in s or s == "":
145
+ escaped = s.replace("\\", "\\\\").replace('"', '\\"')
146
+ return f'"{escaped}"'
145
147
  return s
146
148
 
147
149
 
@@ -159,8 +159,8 @@ def test_encode_non_uniform_list():
159
159
 
160
160
  def test_encode_primitive_value():
161
161
  """A bare primitive is encoded directly."""
162
- assert encode_generic(42) == "42\n"
163
- assert encode_generic("hello") == "hello\n"
162
+ assert encode_generic(42) == "42"
163
+ assert encode_generic("hello") == "hello"
164
164
 
165
165
 
166
166
  def test_encode_string_with_pipe():
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes