Skip to content

refactor(python): refactor python serialization api#3543

Merged
chaokunyang merged 8 commits intoapache:mainfrom
chaokunyang:new_python_api
Apr 8, 2026
Merged

refactor(python): refactor python serialization api#3543
chaokunyang merged 8 commits intoapache:mainfrom
chaokunyang:new_python_api

Conversation

@chaokunyang
Copy link
Copy Markdown
Collaborator

@chaokunyang chaokunyang commented Apr 7, 2026

Why?

Refactor the Python serialization runtime to make serializer ownership and per-operation state explicit. This moves read and write state out of Fory, aligns the Python and Cython code paths around the same context model, and simplifies how custom serializers interact with the runtime.

What does this PR do?

  • Introduces explicit Config, WriteContext, and ReadContext runtime objects and moves serialization state management out of Fory.
  • Refactors Python and Cython serializer APIs to take type_resolver in constructors and to read or write through read_context and write_context instead of raw buffer methods.
  • Reorganizes the Python serialization implementation by moving context-owned logic into context.py and context.pxi, slimming serialization.pyx, and wiring collection, primitive, struct, union, and registry paths through the new boundaries.
  • Updates the Python custom serializer and type registration docs to the new constructor and context-based serializer method signatures.
  • Refreshes the affected Python tests to use the new serializer and runtime context API shape.

Related issues

#3537

AI Contribution Checklist

  • Substantial AI assistance was used in this PR: yes / no
  • If yes, I included a completed AI Contribution Checklist in this PR description and the required AI Usage Disclosure.

Does this PR introduce any user-facing change?

This refactor changes the Python custom serializer constructor and read or write method signatures, and updates the Python docs accordingly.

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

Benchmark

@chaokunyang chaokunyang force-pushed the new_python_api branch 2 times, most recently from 3084dc3 to afb0bde Compare April 8, 2026 07:47
@chaokunyang chaokunyang merged commit 9b5e154 into apache:main Apr 8, 2026
67 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.

2 participants