# C-API for initializing statically linked extension modules

**URL:** <https://discuss.python.org/t/c-api-for-initializing-statically-linked-extension-modules/43396>\
**Category:** C API\
**Tags:** c-api\
**Created:** [January 17, 2024, 6:45am UTC](https://discuss.python.org/t/c-api-for-initializing-statically-linked-extension-modules/43396 "2024-01-17T06:45:11Z")\
**Posts on this page:** 1\
**Showing post:** 32

<div class="post-metadata">

**Author:** ![steve.dower](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/steve.dower/32/56_2.png) [@steve.dower](https://discuss.python.org/u/steve.dower)\
**Post date:** [February 21, 2024, 1:30pm UTC](https://discuss.python.org/t/c-api-for-initializing-statically-linked-extension-modules/43396/32 "2024-02-21T13:30:25Z")

</div>

The internals here feel _very_ unstable to me, in the sense that we’d just replace the whole thing with a more direct approach if we had infinite resources. Plus we’ve already essentially deprecated single-phase init (both subinterpreters and nogil will block/severely warn about it, IIUC).

> [@guido](#):
>
> Assuming we all agree that it’s simply the full package name, maybe we should rename it `PyUnstable_CallInitFuncWithFullName`? Although I can also see the merit in keeping the `Context` term, which is used consistently in the implementation.

I think `Context` is intended to mean it’s opaque, so this renaming probably sacrifices that. But I suspect it’s fully internal right now, so making it public at all necessitates adding more functions to create/set/free it.

Is there a higher level function we can offer, perhaps - `PyImport_ImportByInitFunc(const char *fullname, initfunc func)`? That way a customer importer can find/know the function itself and turn it into a module object, which seems to be the main aim here. (Presumably such a function already exists for ourselves to import from inittab.)

(Also agree on getting @eric.snow’s thoughts, particularly around how likely we are to refactor import and/or totally deprecate single-phase init.)

---

_[View the full topic](https://discuss.python.org/t/c-api-for-initializing-statically-linked-extension-modules/43396)._
