# Link \`PyInit\` built object against other files

**URL:** <https://forum.modular.com/t/link-pyinit-built-object-against-other-files/3113>\
**Category:** Python Interop\
**Created:** [May 26, 2026, 4:18pm UTC](https://forum.modular.com/t/link-pyinit-built-object-against-other-files/3113 "2026-05-26T16:18:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tedmoore](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/tedmoore/32/912_2.png) [@tedmoore](https://forum.modular.com/u/tedmoore)\
**Post date:** [May 26, 2026, 4:18pm UTC](https://forum.modular.com/t/link-pyinit-built-object-against-other-files/3113/1 "2026-05-26T16:18:19Z")

</div>

Greetings,

The example below calls on a lot of other Mojo code that _all_ gets recompiled when any piece of the program changes. (This happens when this PythonObject is “imported” in Python code).

Also, the code that it relies on is required to exist in the current _PATH_, it would be nice to allow the code it calls upon to live elsewhere and just point the Mojo compiler to where to find it.

**When creating a PythonObject with the interop (such as below), is there a way to _link_ against other Mojo code files (or precompiled code)?**

Also, I have gathered from error messages that building a PythonObject like this with the interop requires it to be `Movable`? Is there a way to remove this requirement?

Thanks!

T

```mojo
def PyInit_GrainsBridge() -> PythonObject:
    try:
        var m = PythonModuleBuilder("GrainsBridge")

        # var person_type = mb.add_type[Person]("Person")
        _ = m.add_type[MMMAudioBridge]("MMMAudioBridge").def_py_init[MMMAudioBridge.py_init]()
            .def_method[MMMAudioBridge.next]("next")
            .def_method[MMMAudioBridge.set_screen_dims]("set_screen_dims")
            .def_method[MMMAudioBridge.update_mouse_pos]("update_mouse_pos")
            .def_method[MMMAudioBridge.update_bool_msg]("update_bool_msg")
            .def_method[MMMAudioBridge.update_bools_msg]("update_bools_msg")
            .def_method[MMMAudioBridge.update_float_msg]("update_float_msg")
            .def_method[MMMAudioBridge.update_floats_msg]("update_floats_msg")
            .def_method[MMMAudioBridge.update_int_msg]("update_int_msg")
            .def_method[MMMAudioBridge.update_ints_msg]("update_ints_msg")
            .def_method[MMMAudioBridge.update_trig_msg]("update_trig_msg")
            .def_method[MMMAudioBridge.update_trigs_msg]("update_trigs_msg")
            .def_method[MMMAudioBridge.update_string_msg]("update_string_msg")
            .def_method[MMMAudioBridge.update_strings_msg]("update_strings_msg")
            .def_method[MMMAudioBridge.set_channel_count]("set_channel_count")  

        return m.finalize()
    except e:
        _ = Error(String("error creating Python Mojo module: " + String(e)))
        abort()

```

---

<div class="post-metadata">

**Author:** ![spluta](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@spluta](https://forum.modular.com/u/spluta)\
**Post date:** [June 19, 2026, 1:55pm UTC](https://forum.modular.com/t/link-pyinit-built-object-against-other-files/3113/2 "2026-06-19T13:55:30Z")

</div>

I guess to follow up on Ted’s question. In 1.0.beta2 we choose the “c abi” for Python Interop. Does this mean that the emitted “c abi” can be linked from any language?

In general, this would be amazing. Create and test in python. Compile. Use in Rust/C/etc.

For our project, this would be magic. Create and test in MMMAudio. Compile. Embed MMMAudio instance (Mojo.so file) in a JUCE VST plugin. Use in any DAW.

---

<div class="post-metadata">

**Author:** ![owenhilyard](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/owenhilyard/32/41_2.png) [@owenhilyard](https://forum.modular.com/u/owenhilyard)\
**Post date:** [June 19, 2026, 3:43pm UTC](https://forum.modular.com/t/link-pyinit-built-object-against-other-files/3113/3 "2026-06-19T15:43:53Z")

</div>

Mojo’s compiler currently doesn’t have great incremental compilation support (Don’t worry, we are **VERY** aware of this as an issue since it actively increases CI costs) and it is also “LTO native” to paraphrase Chris. The Mojo compiler does parallelism internally, so a lot of the traditional advantages of split compilation don’t apply, aside from the caching advantages which can be gained in other ways.

> Also, I have gathered from error messages that building a PythonObject like this with the interop requires it to be `Movable`? Is there a way to remove this requirement?

The struct needs to be moved into a python object, so I don’t think that there is. You can try adding some indirection and putting whatever can’t be moved into another allocation.

---

<div class="post-metadata">

**Author:** ![owenhilyard](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/owenhilyard/32/41_2.png) [@owenhilyard](https://forum.modular.com/u/owenhilyard)\
**Post date:** [June 19, 2026, 3:46pm UTC](https://forum.modular.com/t/link-pyinit-built-object-against-other-files/3113/4 "2026-06-19T15:46:02Z")

</div>

> [@spluta](#):
>
> I guess to follow up on Ted’s question. In 1.0.beta2 we choose the “c abi” for Python Interop. Does this mean that the emitted “c abi” can be linked from any language?

Non-`abi("C")` functions should still work with Python since the compiler can just generate a bit of glue code for you.

For any other language, `abi("C")` is strongly recommended unless you want to match how Mojo does name mangling and argument conventions.
