junrushao opened a new pull request, #438:
URL: https://github.com/apache/tvm-ffi/pull/438
## Summary
- Add `refl::enable_copy()` to the C++ reflection API, which registers a
`__ffi_shallow_copy__` method using the copy constructor
- Implement `ObjectDeepCopier` in `src/ffi/extra/copy.cc` that walks the
object graph (DFS with explicit stack), then copies in topological order
(leaves first) with field replacement
- Wire up Python `__copy__`, `__deepcopy__`, and `__replace__` for both
`@register_object` and `@c_class` paths; types without `enable_copy()` raise
`TypeError`
## Test plan
17 new tests in `tests/python/test_copy.py` covering:
- [x] `copy.copy()`: basic fields, new object identity, mutable fields,
mutation isolation, derived type preservation, unsupported type error
- [x] `copy.deepcopy()`: basic fields, nested object copying, shared
reference preservation, mutation isolation, unsupported type error
- [x] `__replace__()`: single/multiple field replacement, no-kwargs copy,
original unchanged, readonly field error, unsupported type error
## Misc
- Add `--error-on-warning` to the `ty` pre-commit hook
--
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]