gcf-python 2.5.2__py3-none-any.whl → 2.6.0__py3-none-any.whl

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.
gcf/__init__.py CHANGED
@@ -102,4 +102,4 @@ __all__ = [
102
102
  "DEFAULT_REANCHOR_N",
103
103
  ]
104
104
 
105
- __version__ = "2.3.0"
105
+ __version__ = "2.6.0"
gcf/scalar.py CHANGED
@@ -9,8 +9,10 @@ from typing import Any
9
9
  # \Z (end of string), not $, so a trailing newline does not count as the end:
10
10
  # in Python $ also matches just before a final \n, which would misclassify a
11
11
  # string like "5\n" as a number or "W\n" as a bare key and break round-trip.
12
- _JSON_NUMBER_RE = re.compile(r"^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?\Z")
13
- _NUMERIC_LIKE_RE = re.compile(r"^[+-]\.?\d|^\.\d|^0\d")
12
+ # Digits are ASCII 0-9 (SPEC 2.3): \d is avoided because in Python's re it also
13
+ # matches Unicode decimal digits (\p{Nd}), which would accept e.g. "1.<U+0665>".
14
+ _JSON_NUMBER_RE = re.compile(r"^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\Z")
15
+ _NUMERIC_LIKE_RE = re.compile(r"^[+-]\.?[0-9]|^\.[0-9]|^0[0-9]")
14
16
  _INLINE_ARRAY_RE = re.compile(r"\[[^\]]*\]\s*:")
15
17
  _BARE_KEY_RE = re.compile(r"^[a-zA-Z_][a-zA-Z0-9_]*\Z")
16
18
 
@@ -91,6 +93,15 @@ def format_scalar(v: Any, delimiter: str = "") -> str:
91
93
  if isinstance(v, bool):
92
94
  return "true" if v else "false"
93
95
  if isinstance(v, int) and not isinstance(v, bool):
96
+ # The encoder enforces the int64 domain (SPEC 2.3.2): a Python int is
97
+ # arbitrary-precision, so a host integer outside int64 is rejected here
98
+ # rather than emitted as a bare token the decoder would reject.
99
+ if v < -(2**63) or v > 2**63 - 1:
100
+ raise ValueError(
101
+ f"out_of_range: integer {v} is outside the canonical int64 "
102
+ "domain [-9223372036854775808, 9223372036854775807]; "
103
+ "model larger values as strings (SPEC 2.3.2)"
104
+ )
94
105
  return str(v)
95
106
  if isinstance(v, float):
96
107
  return format_number(v)
@@ -109,7 +120,12 @@ def format_number(f: float) -> str:
109
120
  # Negative zero canonicalizes to 0 (SPEC 2.3.1): -0.0 equals 0.0 by value.
110
121
  return "0"
111
122
  a = abs(f)
112
- if 1e-6 <= a < 1e21:
123
+ # Plain decimal only below 2^53. Every double at or above 2^53 is integer-valued,
124
+ # so a plain rendering would emit a bare-integer token: indistinguishable from an
125
+ # int64 on the wire and beyond the binary64 safe-integer range (2^53-1), so a
126
+ # JavaScript decoder rejects it under its default policy. Exponent shape keeps bare
127
+ # tokens int64 and decimal/exponent tokens doubles (SPEC 2.3.1). Ints format above.
128
+ if 1e-6 <= a < 2**53:
113
129
  # Use repr for shortest round-trippable form.
114
130
  s = repr(f)
115
131
  # If repr chose scientific notation, convert to plain decimal.
@@ -163,12 +179,20 @@ def parse_scalar(s: str, tabular_context: bool = False) -> Any:
163
179
  if s == "false":
164
180
  return False
165
181
  if _JSON_NUMBER_RE.match(s):
182
+ # Token shape follows domain (SPEC 2.3.2): a bare-integer literal (no
183
+ # fraction, no exponent) is an int64-domain integer parsed exactly, not
184
+ # routed through float(); a decimal or exponent literal is a double.
185
+ if "." not in s and "e" not in s and "E" not in s:
186
+ n = int(s)
187
+ if n < -(2**63) or n > 2**63 - 1:
188
+ raise ValueError(
189
+ f"out_of_range: integer {s} is outside the canonical int64 "
190
+ "domain [-9223372036854775808, 9223372036854775807]; "
191
+ "model larger values as strings (SPEC 2.3.2)"
192
+ )
193
+ return n
166
194
  try:
167
- f = float(s)
168
- if "." not in s and "e" not in s and "E" not in s:
169
- if abs(f) <= 2**53:
170
- return int(f)
171
- return f
195
+ return float(s)
172
196
  except ValueError:
173
197
  pass
174
198
  return s
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: gcf-python
3
- Version: 2.5.2
3
+ Version: 2.6.0
4
4
  Summary: The AI-native wire format for structured data. 50-92% fewer tokens than JSON, with multi-turn delta encoding for agent loops. 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://gcformat.com/
@@ -304,7 +304,7 @@ GCF wins 15/16 datasets on the expanded [token efficiency benchmark](https://git
304
304
 
305
305
  **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.
306
306
 
307
- **Specification:** [SPEC v3.5.0 Stable](https://github.com/blackwell-systems/gcf/blob/main/SPEC.md) with 264 conformance fixtures, 43,000,000,000+ lossless round-trips verified across 5 formats and 6 languages. All implementations at v2.5.1+ (Go v1.6.1, Swift v2.6.0). Cross-language 6x6 matrix verified.
307
+ **Specification:** [SPEC v3.5.2 Stable](https://github.com/blackwell-systems/gcf/blob/main/SPEC.md) with 269 conformance fixtures, 43,000,000,000+ lossless round-trips verified across 5 formats and 6 languages. Current versions: Go v1.6.2, TypeScript v2.5.2, Python v2.5.3, Rust v2.5.3, Swift v2.6.2, Kotlin v2.5.2, .NET v0.1.2. Cross-language conformance verified across all seven SDKs.
308
308
 
309
309
  ## Adopted by
310
310
 
@@ -1,4 +1,4 @@
1
- gcf/__init__.py,sha256=dZkdcjbG-dcolg_7TBROjRq3opftDGU423ankMIOhyA,2616
1
+ gcf/__init__.py,sha256=QRGOX87aJR1RXZktNnzRgYbqM7Fp9i1ZPIAf97wE-o8,2616
2
2
  gcf/__main__.py,sha256=EpvBz1yc8H0D5OJ1zy2tYke-kRzvudKa4DEbfeW14ao,71
3
3
  gcf/cli.py,sha256=UEe1CAZn-rKGNIo_ap8-oez3ucl6DSRbsdv6RDnzygY,5256
4
4
  gcf/constants.py,sha256=cmZ8YJSOB0im_eyfN8v4UvrLpBC6Fuf4cfcKZGbutxY,638
@@ -10,13 +10,13 @@ gcf/generic.py,sha256=1c53utF2GcD8lS_wks2opQw08hMz4KGL-7C8g7JB5bA,21577
10
10
  gcf/generic_delta.py,sha256=5KSUT_QUeH7OILLWfu9JveaXRSrqRIi3c6E8WjlgC4Q,18785
11
11
  gcf/keyed_map.py,sha256=qCwhehXB1FQ2iYCPhcvXOqGwrVqdXhGYZGxv56CSUgc,3644
12
12
  gcf/packroot.py,sha256=0rZY7TEVcLzA8XhoIOc6_g9lbRCn-MUr54YTRVhzsO4,2019
13
- gcf/scalar.py,sha256=NMf-ZJzTOGk1JLvydqYPRxUH80u2Sr_bonwRHXTYd5U,9856
13
+ gcf/scalar.py,sha256=fQvfYLuJVbrbB46fd0V1BPDdVaxdthaOsrZJ2B8l2Gk,11499
14
14
  gcf/session.py,sha256=rPqR4xsHKpi_G37t1ODwkTUdHhVAGa3Uig8F60h34Ms,5335
15
15
  gcf/stream.py,sha256=3eyzmLMZPyEGC1MS9pujxio2x_t7rCL-eNuJ4DjYkaA,5938
16
16
  gcf/stream_generic.py,sha256=h2mJ-jI-c1H2L0uoQVhrvDc7uJEcOwS1MB51k4SCPNM,5775
17
17
  gcf/types.py,sha256=AWm-LQoSqLHAYtEjcAxWQZqJ4JXqNreLUKO2mJFgNMA,1465
18
- gcf_python-2.5.2.dist-info/METADATA,sha256=Cnwh-CZYYXbQqcQyp8rKTHq5U_MnFzXZ1O4muLdaTss,16082
19
- gcf_python-2.5.2.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
20
- gcf_python-2.5.2.dist-info/entry_points.txt,sha256=aFT6gqlkh8iGfM8cblE-LUMxHH08_v71IIoZtDdRIVA,37
21
- gcf_python-2.5.2.dist-info/licenses/LICENSE,sha256=2Fit9wnaIe--RMSAgyQqxC5hfZTyZqn4fIdBtp9qPDw,1072
22
- gcf_python-2.5.2.dist-info/RECORD,,
18
+ gcf_python-2.6.0.dist-info/METADATA,sha256=0iJSJoi00y_XFo6x3cM7lq5mp9JuShcf3VFfCYYbov4,16165
19
+ gcf_python-2.6.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
20
+ gcf_python-2.6.0.dist-info/entry_points.txt,sha256=aFT6gqlkh8iGfM8cblE-LUMxHH08_v71IIoZtDdRIVA,37
21
+ gcf_python-2.6.0.dist-info/licenses/LICENSE,sha256=2Fit9wnaIe--RMSAgyQqxC5hfZTyZqn4fIdBtp9qPDw,1072
22
+ gcf_python-2.6.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.31.0
2
+ Generator: hatchling 1.32.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any