Spaces:
Running on Zero
Running on Zero
Download src/solarwm/runtime/serialization.py from hugging-apps/solarrenderer: direct link, hf CLI and curl.
- Browser
- Download file 618 Bytes
-
https://huggingface.co/spaces/hugging-apps/solarrenderer/resolve/main/src/solarwm/runtime/serialization.py
- Command line
-
hf download hf://spaces/hugging-apps/solarrenderer/src/solarwm/runtime/serialization.py
-
curl -L -o serialization.py https://huggingface.co/spaces/hugging-apps/solarrenderer/resolve/main/src/solarwm/runtime/serialization.py
618 Bytes
| """Deterministic serialization helpers shared by runtime artifacts.""" | |
| from __future__ import annotations | |
| import json | |
| from typing import Any | |
| def canonical_json_bytes(value: Any, *, trailing_newline: bool = True) -> bytes: | |
| """Serialize JSON deterministically and reject non-standard numeric values.""" | |
| suffix = "\n" if trailing_newline else "" | |
| return ( | |
| json.dumps( | |
| value, | |
| allow_nan=False, | |
| ensure_ascii=False, | |
| separators=(",", ":"), | |
| sort_keys=True, | |
| ) | |
| + suffix | |
| ).encode("utf-8") | |
| __all__ = ["canonical_json_bytes"] | |