You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by "Dayuxiaoshui (via GitHub)" <gi...@apache.org> on 2026/01/14 10:13:42 UTC

Re: [I] [FEAT] Support Mutable variant of Array [tvm-ffi]

Dayuxiaoshui commented on issue #350:
URL: https://github.com/apache/tvm-ffi/issues/350#issuecomment-3748791981

   @tqchen We understand this requirement. While the current immutable + COW design of Array provides benefits for unified tuple/map handling, there's a clear need for controlled mutability. We propose adding __setitem__ at the Python layer leveraging the existing COW mechanism, exposing ArraySetItem via FFI. This maintains backward compatibility (arrays remain immutable by default) while enabling arr[i] = value syntax. When the array has a unique reference, modifications happen in-place; multiple references trigger COW. The implementation is added to src/ffi/container.cc and python/tvm_ffi/container.py, ready to use. This approach preserves the semantic benefits of immutability while providing flexible mutability when needed.


-- 
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: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org