embedding python in C++

Syver Enstad syver at NOSPAMcyberwatcher.com
Tue Jan 9 08:28:47 EST 2001


"Alex Martelli" <aleaxit at yahoo.com> wrote in message
news:93cq6n0186t at news1.newsguy.com...
> You could do it all in C++ without real pain -- whence, the 'somewhat' in
> my sentence above, rather than 'massively':-): instantiating the Python
> type C++ object (which need only implement a 'write' method, and let
> 'softspace' be set & gotten from Python) in C++, and using, again from
C++,
Mmm, that's what I did, didn't implement the softspace attribute though.
What's it for anyway?

> PyObject_SetAttrString to set it directly as the 'stdout' attribute of
> the sys module.

I did that from python instead.

>on the basis of "do the simplest
> thing that can possibly work", it's probably best avoided anyway.
Yeah, shave it with Occam's razor!

> Another principle (a corollary of the main one) being, of course, "as
little
> C++ as you can possibly get away with":-).
Yes, but sometimes it's fun struggle with C++ too, but it generally
dispappears when I start trying to reuse things which is a real pain in C++,
not to mention runtime libraries, and the need to have a lib compiled in at
least 4 different versions dependening on which other libraries you link
with.

>Personally, I currently use the Boost Python Library (BPL), at
> www.boost.org, for all C++/Python work that I don't do through COM (with
> the sole exception of what I need to do in C for general acceptance:-).

Yes, boost looks interesting. I've downloaded it, but I don't think I'll use
it before I have a better grasp of the underlying API.

> Sorry, can't help you here, either.  If I _was_ in a threading-is-crucial,
> Win32-only situation, I'd be *certain* to use ActiveScripting, which
> *ensures* I can instantiate just as many interpreters as I need (and they
> _shouldn't_ thread on each other toes -- though I have NOT had occasion
> to test this... as threading is another of those "the least I can possibly
> get away with" complications, in my worldview:-).

Okay, do you have any examples on how to use that instead?
>
> Very interest project, anyway -- best of luck!

Nah, it's just something I enjoy fiddling with at home, we'll see if it ever
reaches something near to finished, but it looks promising just now.





More information about the Python-list mailing list