Skip to content

Conversation

@t-kalinowski
Copy link
Member

@t-kalinowski t-kalinowski commented Dec 15, 2025

This PR keeps the public Python API (parse_yaml, read_yaml, format_yaml, write_yaml) intact, but refactors the tagged-wrapper type and tightens tag + formatting behavior/perf.

  • yaml12.Yaml is now a native Rust pyclass: immutable .value/.tag, hashable, picklable, and proxies mapping/sequence operations when wrapping collections/keys.
  • Tag semantics are now explicit: non-core tags are preserved as Yaml; core scalar tags (!!str/!!int/!!float/!!bool/!!null/!!seq/!!map) normalize to plain Python values, while informative core tags (e.g. !!timestamp, !!binary) stay tagged unless handled.
  • Handler normalization: handler keys can be !foo/foo, verbatim !<...> and %TAG-expanded URIs, and core shorthand !!timestamp/!!binary.
  • parse_yaml accepts str or any iterable of str chunks (concatenated exactly; no implicit newline insertion).
  • format_yaml round-trips float edge cases (1.0, -0.0, inf, -inf, nan), drops core scalar tags on emit, and rejects bytes/bytearray inputs (use str + tags/handlers for binary data).
  • Unhashable mapping keys are wrapped in Yaml and compare/hash structurally (including mapping insertion order) so they can round-trip safely.
  • Performance: format_yaml borrows Python str values zero-copy during conversion, and handler lookups are cached.
  • Docs/typing/tests updated to match the extension runtime; packaging/docs now use the PyPI name py-yaml12.

Move the Yaml dataclass into python/yaml12 (bytecode-cached; prints as yaml12.Yaml)
Add internal _set_yaml_class init hook and remove Rust-side exec bootstrap
Normalize handler keys and tags (gizmo, !<gizmo>, !!timestamp)
Improve tag parsing/emission and float scalar formatting
Update docs and tests; rename the PyPI project to py-yaml12
@t-kalinowski t-kalinowski changed the title yaml12: Python-sourced Yaml + tag/handler polish yaml12: Python-side Yaml wrapper + tag/handler normalization Dec 16, 2025
Replace runtime Python/dataclass bootstrap with a Rust-backed Yaml class.

- Preserve tag wrapping, hash/equality, and proxying semantics
- Update stubs and docs, and add tests for the new code path
@t-kalinowski t-kalinowski changed the title yaml12: Python-side Yaml wrapper + tag/handler normalization yaml12: make Yaml a native Rust class Dec 16, 2025
- Raise TypeError for bytes/bytearray instead of emitting sequences of ints

- Clarify reader UTF-8 decode errors to reference reader.read()

- Add tests for bytes-like rejection
- Borrow UTF-8 buffers from Python strings via an arena

- Keep strong PyString refs to allow emitting while GIL is released

- Add PyPI install instructions to docs index
@t-kalinowski t-kalinowski changed the title yaml12: make Yaml a native Rust class yaml12: native Yaml wrapper + tag/formatting polish Dec 16, 2025
@t-kalinowski t-kalinowski merged commit a395455 into main Dec 16, 2025
17 checks passed
@t-kalinowski t-kalinowski deleted the pr/core-polish branch December 16, 2025 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants