junrushao commented on issue #350: URL: https://github.com/apache/tvm-ffi/issues/350#issuecomment-3874835389
I have some different thoughts regarding this task as I encounter a few issues. While CoW property is indeed used in a few TIR/Relax passes, it's absolutely an anti-pattern to have such complex semantics if the behavior of a program depends on reference counters which are supposed to be implementation details. In dataclass's [`frozen=True`](https://docs.python.org/3/library/dataclasses.html#frozen-instances) mode, there's an inherit need to switch between frozen (immutable) and non-frozen (mutable) instances. In this case, I suspect it would be extremely challenging to convert from frozen (`InplaceArray`-based) to non-frozen (out-of-place `data_` ptr with an extra `data_deleter_`), mutate, and converting back without resorting to copying. Resorting to copy would incur correctness issues as pointer reference got invalidated. The benefit of having inplace arrays are minimal and I didn't see a real killer app. Therefore, in my opinion, it's extremely compelling to get rid of this non-standard behavior and convert to mutability first. It means either breaking change, or having a separate List/Dict classes which are standard mutable containers. -- 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]
