chaokunyang commented on code in PR #2400:
URL: https://github.com/apache/fory/pull/2400#discussion_r2195587725
##########
python/pyfory/serializer.py:
##########
@@ -703,6 +703,59 @@ def to_buffer(self) -> "Buffer":
return Buffer(self.binary)
+class StatefulSerializer(CrossLanguageCompatibleSerializer):
+ """
+ Serializer for objects that support __getstate__ and __setstate__.
+ Uses Fory's native serialization for better cross-language support.
+ """
+
+ def __init__(self, fory, cls):
+ super().__init__(fory, cls)
+ self.cls = cls
+
+ def write(self, buffer, value):
+ # Get the state using __getstate__
+ state = value.__getstate__()
+
+ # Check for constructor arguments
+ args = ()
+ kwargs = {}
+
+ if hasattr(value, "__getnewargs_ex__"):
Review Comment:
Or we can left this in future PR, current implementation has better
compatibility
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]