junrushao commented on code in PR #438:
URL: https://github.com/apache/tvm-ffi/pull/438#discussion_r2791488179


##########
include/tvm/ffi/reflection/registry.h:
##########
@@ -460,6 +460,49 @@ struct init {
   }
 };
 
+/*!
+ * \brief Helper class to enable copy support for object types.
+ *
+ * This helper is used with `ObjectDef::def()` to register 
`__ffi_shallow_copy__`
+ * as an instance method. This enables `__copy__`, `__deepcopy__`, and 
`__replace__`
+ * in Python via the `copy` module.
+ *
+ * The shallow copy uses the C++ copy constructor of the object type:
+ * `make_object<Class>(*self)`.
+ *
+ * Example usage:
+ *
+ * \code{.cpp}
+ * refl::ObjectDef<MyObject>()
+ *     .def(refl::enable_copy())
+ *     .def(refl::init<int64_t, std::string>());
+ * \endcode
+ *
+ * \note The object type must have a copy constructor.
+ */
+struct enable_copy {

Review Comment:
   alternatively, let's enable copy by default for all object types which are 
copy_constructible



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