Skip to content

refactor(python): unify read/write api for python xlang and native mode#3348

Merged
chaokunyang merged 3 commits intoapache:mainfrom
chaokunyang:unify_pyfory_serialization_api
Feb 18, 2026
Merged

refactor(python): unify read/write api for python xlang and native mode#3348
chaokunyang merged 3 commits intoapache:mainfrom
chaokunyang:unify_pyfory_serialization_api

Conversation

@chaokunyang
Copy link
Copy Markdown
Collaborator

@chaokunyang chaokunyang commented Feb 18, 2026

Why?

  • Python currently maintains separate serializer APIs (write/read vs xwrite/xread) and separate runtime paths for native vs xlang serialization, which duplicates logic and increases maintenance cost.
  • Unifying the Python serializer API and runtime path simplifies custom serializer development and keeps behavior aligned across modes.

What does this PR do?

  • Unifies Python serializer APIs to write/read and removes mode-specific xwrite/xread methods from serializer implementations.
  • Removes XlangCompatibleSerializer from Python exports and updates custom serializer docs/examples to the unified API.
  • Refactors Python runtime serialization/deserialization internals to a single write_ref/write_no_ref and read_ref/read_no_ref path, removing x-prefixed duplicates.
  • Unifies dataclass and union serializer implementations/codegen to use the shared read/write path in both xlang and non-xlang modes.
  • Makes field_nullable apply regardless of xlang, and updates Python docs accordingly.
  • Updates Python tests to validate the unified serializer API and generated code paths.

Related issues

Closes #3347

Does this PR introduce any user-facing change?

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

@chaokunyang chaokunyang force-pushed the unify_pyfory_serialization_api branch from ec41a84 to 566e5c6 Compare February 18, 2026 13:18
@chaokunyang chaokunyang merged commit bef6bdc into apache:main Feb 18, 2026
63 checks passed
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.

[Python] Unify pyfory serializer api for native and xlang mode

2 participants