A few SWIG/Python questions

D

Derek Allen

I'm using SWIG to generate glue code for my embedded/extended python app.
There are a couple of very frustrating issues that I would like to see if
anyone else has solutions for:

- Once I have created and initialized a module with SWIG I can call it by
executing a python file with no problems. However I would like to be able to
type in a single-line python function and have it execute from my module.
One line cannot contain both "import _mypackage" and
"_mypackage.DoFunction("hello")" (and even if it could it would be
cumbersome). I cannot find a way to manually import (in code) the methods
from my package prior to executing the single-line instruction. I can get
the dictionary but that doesn't give me the methods. How do I do this?

- For some reason whatever name I give the module (via %module name) ends up
with an underscore at its beginning - e.g., _name. I don't know why this is,
and it was the source of some serious hair-pulling. Is there a way to turn
this off (without recompiling the swig executable)?

- SWIG in general generates a TON of code for the glue module. Is there a
way to reduce this?

- SWIG wraps everything with extern "C", which is unnecessary for my code
and requires me to decorate functions unnecessarily. Is there a way to turn
this off?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,222
Messages
2,571,138
Members
47,755
Latest member
Grazynkaa

Latest Threads

Top