Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Loading an imported module (C API)

1 view
Skip to first unread message

booncw

unread,
Apr 6, 2010, 9:58:47 AM4/6/10
to
Hi,

I am running a simulation where the python module has already been
imported. Could you please tell me how to load it?

I've been doing this (importing everytime), but it is too slow:
pModule = PyImport_Import(pName);


Yours,

Boon

Christian Heimes

unread,
Apr 8, 2010, 6:26:44 AM4/8/10
to pytho...@python.org

You can cache the module object in a static variable:

static PyObject *module = NULL;
if (module == NULL && (module = PyImport_ImportModuleNoBlock("module"))
== NULL) {
return NULL;
}
}

Christian

0 new messages