chaokunyang opened a new issue, #3347:
URL: https://github.com/apache/fory/issues/3347

   ### Feature Request
   
   
   current pyfory has two sets of API `write/read` vs `xwrite/xread`:
   ```
   cdef class Serializer:
       """
       Base class for type-specific serializers.
   
       Serializer defines the interface for serializing and deserializing 
objects of a
       specific type. Each serializer implements two modes:
   
       - Python-native mode (write/read): Optimized for Python-to-Python 
serialization,
         supporting all Python-specific features like __reduce__, local 
functions, etc.
   
       - Cross-language mode (xwrite/xread): Serializes to a cross-language 
format
         compatible with other Fory implementations (Java, Go, Rust, C++, etc).
   
       Custom serializers can be registered for user-defined types using
       Fory.register_serializer() to override default serialization behavior.
   
       Attributes:
           fory: The Fory instance this serializer belongs to
           type_: The Python type this serializer handles
           need_to_write_ref: Whether reference tracking is needed for this type
   
       Note:
           This is a base class for implementing custom serializers. Subclasses 
must
           implement write(), read(), xwrite(), and xread() methods.
       """
       cdef readonly Fory fory
       cdef readonly object type_
       cdef public c_bool need_to_write_ref
   
       def __init__(self, fory, type_: Union[type, TypeVar]):
           self.fory = fory
           self.type_ = type_
           self.need_to_write_ref = fory.track_ref and not 
is_primitive_type(type_)
   
       cpdef write(self, Buffer buffer, value):
           raise NotImplementedError(f"write method not implemented in 
{type(self)}")
   
       cpdef read(self, Buffer buffer):
           raise NotImplementedError(f"read method not implemented in 
{type(self)}")
   
       cpdef xwrite(self, Buffer buffer, value):
           raise NotImplementedError(f"xwrite method not implemented in 
{type(self)}")
   
       cpdef xread(self, Buffer buffer):
           raise NotImplementedError(f"xread method not implemented in 
{type(self)}")
   
       @classmethod
       def support_subclass(cls) -> bool:
           return False
   ```
   
   ```python
   class Serializer(ABC):
       __slots__ = "fory", "type_", "need_to_write_ref"
   
       def __init__(self, fory, type_: type):
           self.fory = fory
           self.type_: type = type_
           self.need_to_write_ref = fory.track_ref and not 
is_primitive_type(type_)
   
       def write(self, buffer, value):
           raise NotImplementedError
   
       def read(self, buffer):
           raise NotImplementedError
   
       def xwrite(self, buffer, value):
           raise NotImplementedError
   
       def xread(self, buffer):
           raise NotImplementedError
   
       @classmethod
       def support_subclass(cls) -> bool:
           return False
   ```
   
   The two sets API introduce lots of complexbility, in many places, we can go 
to different path based on the `is_xlang` is true or false. but for most types, 
the serialization for two sets of API are same. 
   
   
   ### Is your feature request related to a problem? Please describe
   
   _No response_
   
   ### Describe the solution you'd like
   
   _No response_
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### Additional context
   
   _No response_


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