GLYPH Python
Python implementation of the GLYPH codec.
The primary surface is still codec-first:
- parse and emit values
- JSON bridge helpers
- canonicalization and fingerprinting
- streaming validation
Higher-level agent helpers exist, but they are optional layers on top of the codec.
Install
pip install glyph-py
Quick Start
import glyph
data = {"action": "search", "query": "weather", "max_results": 10}
text = glyph.json_to_glyph(data)
print(text)
restored = glyph.glyph_to_json(text)
assert restored == data
value = glyph.parse('{name=Alice age=30 active=t}')
print(value.get("name").as_str())
print(value.get("age").as_int())
fp = glyph.fingerprint_loose(glyph.from_json(data))
print(fp)
Core Functions
| Function | Description |
|---|---|
parse(text) |
Parse GLYPH text to GValue |
emit(value) |
Emit a GValue as canonical loose GLYPH |
json_to_glyph(data) |
Convert Python data directly to GLYPH text |
glyph_to_json(text) |
Parse GLYPH text to Python data |
from_json(data) |
Convert Python data to GValue |
to_json(value) |
Convert GValue to Python data |
fingerprint_loose(value) |
SHA-256 fingerprint of canonical loose form |
equal_loose(a, b) |
Equality by canonical loose form |
Building Values
from glyph import g, field
team = g.struct(
"Team",
field("name", g.str("Arsenal")),
field("rank", g.int(1)),
)
print(glyph.emit(team))
Streaming Validation
from glyph import StreamingValidator, ToolRegistry
registry = ToolRegistry()
registry.add_tool("search", {
"query": {"type": "str", "required": True},
"max_results": {"type": "int", "min": 1, "max": 100},
})
validator = StreamingValidator(registry)
for token in 'search{query="glyph" max_results=5}':
result = validator.push_token(token)
assert result.complete
assert result.valid
assert result.tool_name == "search"
Optional Higher-Level Layer
The Python package also contains an optional agent-oriented runtime in glyph.agent.
Treat that as an example consumer of the codec layer, not the definition of the format.
For repo-wide docs, start at ../README.md.
Metadata
Release files for glyph-py 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| glyph_py-1.0.1.tar.gz | 63.9 kB | Without provenance | Details for glyph_py-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| glyph_py-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for glyph_py-1.0.1-py3-none-any.whl |
Total release size: 107.7 kB
Release files / glyph_py-1.0.1.tar.gz
| Download URL | glyph_py-1.0.1.tar.gz |
|---|---|
| Size | 63.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6c185367821dc52a05931f502d5fbe129ff236bb847ae1b2c9fde65f6f460f0
|
|
BLAKE2b-256 checksum How to use checksums |
1b1761ec087fefdc27281af4b2c76b7d6592279a974bb6b86cd1493daeab32a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / glyph_py-1.0.1-py3-none-any.whl
| Download URL | glyph_py-1.0.1-py3-none-any.whl |
|---|---|
| Size | 43.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
42a76fc626428c0fa372d648cda3f1e3fb38f11156437b8ebc03c3943dd2c7a4
|
|
BLAKE2b-256 checksum How to use checksums |
1640b67c1a1f5beca75d62e24dc8dd120608e78aaca610dd346ecc0d17342ce1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for glyph-py 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.