# How to pass mutable python objects to C++ ffi functions

**URL:** <https://discuss.tvm.apache.org/t/how-to-pass-mutable-python-objects-to-c-ffi-functions/18848>\
**Category:** Questions\
**Created:** [December 15, 2025, 9:33am UTC](https://discuss.tvm.apache.org/t/how-to-pass-mutable-python-objects-to-c-ffi-functions/18848 "2025-12-15T09:33:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mamodev](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/mamodev/32/6134_2.png) [@mamodev](https://discuss.tvm.apache.org/u/mamodev)\
**Post date:** [December 15, 2025, 9:33am UTC](https://discuss.tvm.apache.org/t/how-to-pass-mutable-python-objects-to-c-ffi-functions/18848/1 "2025-12-15T09:33:48Z")

</div>

Hi, i’m building a tvm ffi extension to integrate it with fastflow hpc parallel engine.

I cannot understand how to pass Mutable objects from python to c++

Maps and Arrays are immutable by default…

It would be nice to have also a mutable version.

---

<div class="post-metadata">

**Author:** ![tqchen](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/tqchen/32/5_2.png) [@tqchen](https://discuss.tvm.apache.org/u/tqchen)\
**Post date:** [December 17, 2025, 12:04am UTC](https://discuss.tvm.apache.org/t/how-to-pass-mutable-python-objects-to-c-ffi-functions/18848/2 "2025-12-17T00:04:59Z")

</div>

one easy way to do that for now is to simply start by wrapping another custom ObjectRef with `std::vector`, feel free to also open an issue on the tvm-ffi repo

---

<div class="post-metadata">

**Author:** ![mamodev](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/mamodev/32/6134_2.png) [@mamodev](https://discuss.tvm.apache.org/u/mamodev)\
**Post date:** [December 17, 2025, 3:17pm UTC](https://discuss.tvm.apache.org/t/how-to-pass-mutable-python-objects-to-c-ffi-functions/18848/3 "2025-12-17T15:17:55Z")

</div>

i did not understand this sorry…

Can you expand on this?

i would be like to have Array and Map mutable

---

<div class="post-metadata">

**Author:** ![tqchen](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/tqchen/32/5_2.png) [@tqchen](https://discuss.tvm.apache.org/u/tqchen)\
**Post date:** [December 20, 2025, 12:21pm UTC](https://discuss.tvm.apache.org/t/how-to-pass-mutable-python-objects-to-c-ffi-functions/18848/4 "2025-12-20T12:21:43Z")

</div>

For now Array and Map are immutable atm, but one can create a new custom ObjectRef that wraps vector, [Python Guide — tvm-ffi](https://tvm.apache.org/ffi/guides/python_guide.html#advanced-register-your-own-object) we can also look into bring mutable variant later, tracking here [[FEAT] Support Mutable variant of Array · Issue #350 · apache/tvm-ffi · GitHub](https://github.com/apache/tvm-ffi/issues/350)
