Several questions about embedding Python
Cameron Laird
claird at lairds.com
Wed May 5 08:22:47 EDT 2004
In article <c79ucp$4i6$1 at news2.netvision.net.il>,
Miki Tebeka <miki.tebeka at zoran.com> wrote:
>Hello All,
>
>I'm trying to extend a hardware simulator (written in C/C++) by
>embedding Python.
>After reading the documentation and playing around several questions
>popped up:
>
>1. Is there a way (using SWIG/Boost.Python ...) to export existing C/C++
>functions other than hand writing the wrapper functions.
>Something like: py_export(a_c_function)
>Since the Python module need to get information from the simulator I
>can't just write pure SWIG wrapper (or can I?)
>
>2. How do I debug the Python code? Since the interpreter is called from
>the simulator application I can't run `pdb' on it.
>
>3. Why on does pyconfig.h decides that `python23_d.lib' should be used
>when _DEBUG is on (IMO is should use Py_DEBUG)? I'm debugging *my*
>application not Python.
.
.
.
I'm sympathetic on 3. Python's compile options ... well, *my*
preferred mental models don't match them well, yet. I have no
feel for the likelihood of a change or workaround here. With
luck, timbot will say a few words.
I don't know how to debug, in this sort of embedding context
in particular; the reason you cite is a good example of why.
I sit and think a lot, so that I understand what my applica-
tions do. I don't use debuggers. I'm still undecided about
whether it's helpful for me to confess that.
Yes, you can use pure SWIG wrappers. I'll be more precise: it
*sounds* as though you're saying SWIG is only for extending Py-
thon, and not embedding Python. This is false; SWIG can be used
to embed Python. Maybe there's a problem with use of SWIG in a
particular approach to embedding; just from what you've written,
though, I think it's reasonable to expect success with SWIG's
use.
--
Cameron Laird <claird at phaseit.net>
Business: http://www.Phaseit.net
More information about the Python-list
mailing list