chaokunyang commented on code in PR #2400:
URL: https://github.com/apache/fory/pull/2400#discussion_r2196479431


##########
python/pyfory/serializer.py:
##########
@@ -703,6 +703,52 @@ 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
+        # Cache the method references as fields in the serializer.
+        self._getnewargs_ex = getattr(cls, "__getnewargs_ex__", None)

Review Comment:
   ```suggestion
           self._getnewargs_func = getattr(cls, "__getnewargs_ex__", None) or 
getattr(cls, "__getnewargs__", None)
   ```



-- 
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]

Reply via email to